
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Scheme · 这是程序员吗</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="xishengcai">
        
        
    
    
    <link rel="stylesheet" href="../../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-disqus/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-prism/prism-base16-ateliersulphurpool.light.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-advanced-emoji/emoji-website.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-anchors/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-katex/katex.min.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-terminal/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-versions-select/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="调度队列.html" />
    
    
    <link rel="prev" href="schedule.html" />
    

    
    <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-chart/c3/c3.min.css">
    <script src="../../../gitbook/gitbook-plugin-chart/c3/d3.min.js"></script>
    <script src="../../../gitbook/gitbook-plugin-chart/c3/c3.min.js"></script>
    

    <script src="../../../gitbook/gitbook-plugin-graph/d3.min.js"></script>
    <script src="../../../gitbook/gitbook-plugin-graph/function-plot.js"></script>    

    
        <link rel="shortcut icon" href='../../../favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../../favicon.ico' type="image/x-icon">
    
    
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"repo":"xishengcai/xisheng.blog","types":["star"],"size":"small"};
    </script>

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://xisheng.vip" target="_blank" class="custom-link">Home</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        <li class="header">Blog</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../../">
            
                <a href="../../../">
            
                    
                        <b>1.1.</b>
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../algorithm/">
            
                <a href="../../algorithm/">
            
                    
                        <b>1.2.</b>
                    
                    Algorithm
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../algorithm/heap.html">
            
                <a href="../../algorithm/heap.html">
            
                    
                        <b>1.2.1.</b>
                    
                    Heap
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../algorithm/readme.html">
            
                <a href="../../algorithm/readme.html">
            
                    
                        <b>1.2.2.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../angular/">
            
                <a href="../../angular/">
            
                    
                        <b>1.3.</b>
                    
                    Angular
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../../angular/1-start.html">
            
                <a href="../../angular/1-start.html">
            
                    
                        <b>1.3.1.</b>
                    
                    Start
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../../angular/2-component.html">
            
                <a href="../../angular/2-component.html">
            
                    
                        <b>1.3.2.</b>
                    
                    Component
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../../angular/3-form.html">
            
                <a href="../../angular/3-form.html">
            
                    
                        <b>1.3.3.</b>
                    
                    Form
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../../angular/readme.html">
            
                <a href="../../angular/readme.html">
            
                    
                        <b>1.3.4.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../database/">
            
                <a href="../../database/">
            
                    
                        <b>1.4.</b>
                    
                    Database
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../../database/mongodb.html">
            
                <a href="../../database/mongodb.html">
            
                    
                        <b>1.4.1.</b>
                    
                    Mongodb
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../../database/readme.html">
            
                <a href="../../database/readme.html">
            
                    
                        <b>1.4.2.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../../docker/">
            
                <a href="../../docker/">
            
                    
                        <b>1.5.</b>
                    
                    Docker
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../../docker/CentOS.html">
            
                <a href="../../docker/CentOS.html">
            
                    
                        <b>1.5.1.</b>
                    
                    CentOS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../../docker/install.html">
            
                <a href="../../docker/install.html">
            
                    
                        <b>1.5.2.</b>
                    
                    Install
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../../docker/readme.html">
            
                <a href="../../docker/readme.html">
            
                    
                        <b>1.5.3.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../../docker/官方shell.html">
            
                <a href="../../docker/官方shell.html">
            
                    
                        <b>1.5.4.</b>
                    
                    官方Shell
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../../golang/">
            
                <a href="../../golang/">
            
                    
                        <b>1.6.</b>
                    
                    Golang
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../../golang/aop.html">
            
                <a href="../../golang/aop.html">
            
                    
                        <b>1.6.1.</b>
                    
                    Aop
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../../golang/base/">
            
                <a href="../../golang/base/">
            
                    
                        <b>1.6.2.</b>
                    
                    Base
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.2.1" data-path="../../golang/base/copy.html">
            
                <a href="../../golang/base/copy.html">
            
                    
                        <b>1.6.2.1.</b>
                    
                    Copy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.2" data-path="../../golang/base/new_and_make.html">
            
                <a href="../../golang/base/new_and_make.html">
            
                    
                        <b>1.6.2.2.</b>
                    
                    New And Make
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.3" data-path="../../golang/base/readme.html">
            
                <a href="../../golang/base/readme.html">
            
                    
                        <b>1.6.2.3.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.4" data-path="../../golang/base/reflect.html">
            
                <a href="../../golang/base/reflect.html">
            
                    
                        <b>1.6.2.4.</b>
                    
                    Reflect
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.5" data-path="../../golang/base/string.html">
            
                <a href="../../golang/base/string.html">
            
                    
                        <b>1.6.2.5.</b>
                    
                    String
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2.6" data-path="../../golang/base/tag.html">
            
                <a href="../../golang/base/tag.html">
            
                    
                        <b>1.6.2.6.</b>
                    
                    Tag
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../../golang/clouser.html">
            
                <a href="../../golang/clouser.html">
            
                    
                        <b>1.6.3.</b>
                    
                    Clouser
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../../golang/err 优雅处理.html">
            
                <a href="../../golang/err 优雅处理.html">
            
                    
                        <b>1.6.4.</b>
                    
                    Err 优雅处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../../golang/go module 2.html">
            
                <a href="../../golang/go module 2.html">
            
                    
                        <b>1.6.5.</b>
                    
                    Go Module 2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../../golang/go_mod.html">
            
                <a href="../../golang/go_mod.html">
            
                    
                        <b>1.6.6.</b>
                    
                    Go Mod
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../../golang/gocraftwork.html">
            
                <a href="../../golang/gocraftwork.html">
            
                    
                        <b>1.6.7.</b>
                    
                    Gocraftwork
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../../golang/oauth.html">
            
                <a href="../../golang/oauth.html">
            
                    
                        <b>1.6.8.</b>
                    
                    Oauth
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../../golang/readme.html">
            
                <a href="../../golang/readme.html">
            
                    
                        <b>1.6.9.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../../golang/swagger.html">
            
                <a href="../../golang/swagger.html">
            
                    
                        <b>1.6.10.</b>
                    
                    Swagger
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="../../golang/tls.html">
            
                <a href="../../golang/tls.html">
            
                    
                        <b>1.6.11.</b>
                    
                    Tls
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.12" >
            
                <span>
            
                    
                        <b>1.6.12.</b>
                    
                    代码走读
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.12.1" data-path="../../golang/代码走读/2020.5.26.html">
            
                <a href="../../golang/代码走读/2020.5.26.html">
            
                    
                        <b>1.6.12.1.</b>
                    
                    2020.5.26
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.13" data-path="../../golang/任务队列/">
            
                <a href="../../golang/任务队列/">
            
                    
                        <b>1.6.13.</b>
                    
                    任务队列
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.13.1" data-path="../../golang/任务队列/gocraft-worker.html">
            
                <a href="../../golang/任务队列/gocraft-worker.html">
            
                    
                        <b>1.6.13.1.</b>
                    
                    Gocraft Worker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.13.2" data-path="../../golang/任务队列/readme.html">
            
                <a href="../../golang/任务队列/readme.html">
            
                    
                        <b>1.6.13.2.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.14" data-path="../../golang/参数校验.html">
            
                <a href="../../golang/参数校验.html">
            
                    
                        <b>1.6.14.</b>
                    
                    参数校验
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../../istio/">
            
                <a href="../../istio/">
            
                    
                        <b>1.7.</b>
                    
                    Istio
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../../istio/readme.html">
            
                <a href="../../istio/readme.html">
            
                    
                        <b>1.7.1.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../../istio/virtualservice.html">
            
                <a href="../../istio/virtualservice.html">
            
                    
                        <b>1.7.2.</b>
                    
                    Virtualservice
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" >
            
                <span>
            
                    
                        <b>1.8.</b>
                    
                    Java
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../../java/jvm.html">
            
                <a href="../../java/jvm.html">
            
                    
                        <b>1.8.1.</b>
                    
                    Jvm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../../java/typescript.html">
            
                <a href="../../java/typescript.html">
            
                    
                        <b>1.8.2.</b>
                    
                    Typescript
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../">
            
                <a href="../">
            
                    
                        <b>1.9.</b>
                    
                    Kubernetes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../APIService.html">
            
                <a href="../APIService.html">
            
                    
                        <b>1.9.1.</b>
                    
                    APIService
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../CAK.html">
            
                <a href="../CAK.html">
            
                    
                        <b>1.9.2.</b>
                    
                    CAK
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../Deployment 的实现原理.html">
            
                <a href="../Deployment 的实现原理.html">
            
                    
                        <b>1.9.3.</b>
                    
                    Deployment 的实现原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="./">
            
                <a href="./">
            
                    
                        <b>1.9.4.</b>
                    
                    K8s源码
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.4.1" data-path="calico 源码分析.html">
            
                <a href="calico 源码分析.html">
            
                    
                        <b>1.9.4.1.</b>
                    
                    Calico 源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.2" data-path="garbage collector controller 源码分析.html">
            
                <a href="garbage collector controller 源码分析.html">
            
                    
                        <b>1.9.4.2.</b>
                    
                    Garbage Collector Controller 源码分析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.3" data-path="job.html">
            
                <a href="job.html">
            
                    
                        <b>1.9.4.3.</b>
                    
                    Job
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.4" data-path="kube-proxy-iptables.html">
            
                <a href="kube-proxy-iptables.html">
            
                    
                        <b>1.9.4.4.</b>
                    
                    Kube Proxy Iptables
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.5" data-path="kube-proxy-ipvs.html">
            
                <a href="kube-proxy-ipvs.html">
            
                    
                        <b>1.9.4.5.</b>
                    
                    Kube Proxy Ipvs
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.6" data-path="kube-proxy.html">
            
                <a href="kube-proxy.html">
            
                    
                        <b>1.9.4.6.</b>
                    
                    Kube Proxy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.7" data-path="kubectl-exec.html">
            
                <a href="kubectl-exec.html">
            
                    
                        <b>1.9.4.7.</b>
                    
                    Kubectl Exec
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.8" data-path="kubectl源码阅读1.html">
            
                <a href="kubectl源码阅读1.html">
            
                    
                        <b>1.9.4.8.</b>
                    
                    Kubectl源码阅读1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.9" data-path="kubectl源码阅读2.html">
            
                <a href="kubectl源码阅读2.html">
            
                    
                        <b>1.9.4.9.</b>
                    
                    Kubectl源码阅读2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.10" data-path="readme.html">
            
                <a href="readme.html">
            
                    
                        <b>1.9.4.10.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.11" data-path="schedule.html">
            
                <a href="schedule.html">
            
                    
                        <b>1.9.4.11.</b>
                    
                    Schedule
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.9.4.12" data-path="scheme.html">
            
                <a href="scheme.html">
            
                    
                        <b>1.9.4.12.</b>
                    
                    Scheme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4.13" data-path="调度队列.html">
            
                <a href="调度队列.html">
            
                    
                        <b>1.9.4.13.</b>
                    
                    调度队列
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../Karmada.html">
            
                <a href="../Karmada.html">
            
                    
                        <b>1.9.5.</b>
                    
                    Karmada
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" data-path="../Pixie.html">
            
                <a href="../Pixie.html">
            
                    
                        <b>1.9.6.</b>
                    
                    Pixie
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.7" data-path="../admission access.html">
            
                <a href="../admission access.html">
            
                    
                        <b>1.9.7.</b>
                    
                    Admission Access
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.8" data-path="../ccm.html">
            
                <a href="../ccm.html">
            
                    
                        <b>1.9.8.</b>
                    
                    Ccm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.9" data-path="../client-go.html">
            
                <a href="../client-go.html">
            
                    
                        <b>1.9.9.</b>
                    
                    Client Go
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.10" data-path="../command.html">
            
                <a href="../command.html">
            
                    
                        <b>1.9.10.</b>
                    
                    Command
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.11" data-path="../controller.html">
            
                <a href="../controller.html">
            
                    
                        <b>1.9.11.</b>
                    
                    Controller
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.12" data-path="../copy docker config.html">
            
                <a href="../copy docker config.html">
            
                    
                        <b>1.9.12.</b>
                    
                    Copy Docker Config
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.13" data-path="../etcd-operation.html">
            
                <a href="../etcd-operation.html">
            
                    
                        <b>1.9.13.</b>
                    
                    Etcd Operation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.14" data-path="../gc.html">
            
                <a href="../gc.html">
            
                    
                        <b>1.9.14.</b>
                    
                    Gc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.15" data-path="../helm chart.html">
            
                <a href="../helm chart.html">
            
                    
                        <b>1.9.15.</b>
                    
                    Helm Chart
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.16" data-path="../helm.html">
            
                <a href="../helm.html">
            
                    
                        <b>1.9.16.</b>
                    
                    Helm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.17" >
            
                <span>
            
                    
                        <b>1.9.17.</b>
                    
                    Helm
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.17.1" data-path="../helm/charts.html">
            
                <a href="../helm/charts.html">
            
                    
                        <b>1.9.17.1.</b>
                    
                    Charts
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.17.2" data-path="../helm/helm 钩子函数.html">
            
                <a href="../helm/helm 钩子函数.html">
            
                    
                        <b>1.9.17.2.</b>
                    
                    Helm 钩子函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.17.3" data-path="../helm/helm-operator.html">
            
                <a href="../helm/helm-operator.html">
            
                    
                        <b>1.9.17.3.</b>
                    
                    Helm Operator
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.17.4" data-path="../helm/文档查询.html">
            
                <a href="../helm/文档查询.html">
            
                    
                        <b>1.9.17.4.</b>
                    
                    文档查询
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.17.5" data-path="../helm/语法.html">
            
                <a href="../helm/语法.html">
            
                    
                        <b>1.9.17.5.</b>
                    
                    语法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9.18" data-path="../install.html">
            
                <a href="../install.html">
            
                    
                        <b>1.9.18.</b>
                    
                    Install
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.19" data-path="../istio-inject.html">
            
                <a href="../istio-inject.html">
            
                    
                        <b>1.9.19.</b>
                    
                    Istio Inject
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.20" >
            
                <span>
            
                    
                        <b>1.9.20.</b>
                    
                    KubeEdge
            
                </span>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.21" data-path="../kuber-apiserver-flag.html">
            
                <a href="../kuber-apiserver-flag.html">
            
                    
                        <b>1.9.21.</b>
                    
                    Kuber Apiserver Flag
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.22" data-path="../kubernetes-client.html">
            
                <a href="../kubernetes-client.html">
            
                    
                        <b>1.9.22.</b>
                    
                    Kubernetes Client
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.23" data-path="../kubernetes灾备.html">
            
                <a href="../kubernetes灾备.html">
            
                    
                        <b>1.9.23.</b>
                    
                    Kubernetes灾备
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.24" data-path="../kubesphere/">
            
                <a href="../kubesphere/">
            
                    
                        <b>1.9.24.</b>
                    
                    Kubesphere
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.24.1" data-path="../kubesphere/helm.html">
            
                <a href="../kubesphere/helm.html">
            
                    
                        <b>1.9.24.1.</b>
                    
                    Helm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.24.2" data-path="../kubesphere/readme.html">
            
                <a href="../kubesphere/readme.html">
            
                    
                        <b>1.9.24.2.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9.25" data-path="../kubevela/">
            
                <a href="../kubevela/">
            
                    
                        <b>1.9.25.</b>
                    
                    Kubevela
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.25.1" data-path="../kubevela/KubeVela 功能.html">
            
                <a href="../kubevela/KubeVela 功能.html">
            
                    
                        <b>1.9.25.1.</b>
                    
                    KubeVela 功能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.2" data-path="../kubevela/cue.html">
            
                <a href="../kubevela/cue.html">
            
                    
                        <b>1.9.25.2.</b>
                    
                    Cue
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.3" data-path="../kubevela/oam.html">
            
                <a href="../kubevela/oam.html">
            
                    
                        <b>1.9.25.3.</b>
                    
                    Oam
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.4" data-path="../kubevela/readme.html">
            
                <a href="../kubevela/readme.html">
            
                    
                        <b>1.9.25.4.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.5" data-path="../kubevela/rollout design.html">
            
                <a href="../kubevela/rollout design.html">
            
                    
                        <b>1.9.25.5.</b>
                    
                    Rollout Design
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.6" data-path="../kubevela/vela run.html">
            
                <a href="../kubevela/vela run.html">
            
                    
                        <b>1.9.25.6.</b>
                    
                    Vela Run
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.7" data-path="../kubevela/vela up.html">
            
                <a href="../kubevela/vela up.html">
            
                    
                        <b>1.9.25.7.</b>
                    
                    Vela Up
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.8" data-path="../kubevela/vela-cluster.html">
            
                <a href="../kubevela/vela-cluster.html">
            
                    
                        <b>1.9.25.8.</b>
                    
                    Vela Cluster
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.9" data-path="../kubevela/vela-helm.html">
            
                <a href="../kubevela/vela-helm.html">
            
                    
                        <b>1.9.25.9.</b>
                    
                    Vela Helm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.25.10" data-path="../kubevela/vela-pk-oam.html">
            
                <a href="../kubevela/vela-pk-oam.html">
            
                    
                        <b>1.9.25.10.</b>
                    
                    Vela Pk Oam
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9.26" data-path="../mk-cert.html">
            
                <a href="../mk-cert.html">
            
                    
                        <b>1.9.26.</b>
                    
                    Mk Cert
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.27" data-path="../open_swagger-ui.html">
            
                <a href="../open_swagger-ui.html">
            
                    
                        <b>1.9.27.</b>
                    
                    Open Swagger Ui
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.28" data-path="../readme.html">
            
                <a href="../readme.html">
            
                    
                        <b>1.9.28.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29" data-path="../task/">
            
                <a href="../task/">
            
                    
                        <b>1.9.29.</b>
                    
                    Task
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.29.1" data-path="../task/HPA.html">
            
                <a href="../task/HPA.html">
            
                    
                        <b>1.9.29.1.</b>
                    
                    HPA
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29.2" data-path="../task/kubectl patch.html">
            
                <a href="../task/kubectl patch.html">
            
                    
                        <b>1.9.29.2.</b>
                    
                    Kubectl Patch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29.3" data-path="../task/pod 信息注入.html">
            
                <a href="../task/pod 信息注入.html">
            
                    
                        <b>1.9.29.3.</b>
                    
                    Pod 信息注入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29.4" data-path="../task/pod 垂直扩缩容.html">
            
                <a href="../task/pod 垂直扩缩容.html">
            
                    
                        <b>1.9.29.4.</b>
                    
                    Pod 垂直扩缩容
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29.5" data-path="../task/readme.html">
            
                <a href="../task/readme.html">
            
                    
                        <b>1.9.29.5.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29.6" data-path="../task/server-side-apply.html">
            
                <a href="../task/server-side-apply.html">
            
                    
                        <b>1.9.29.6.</b>
                    
                    Server Side Apply
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29.7" data-path="../task/准入控制.html">
            
                <a href="../task/准入控制.html">
            
                    
                        <b>1.9.29.7.</b>
                    
                    准入控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29.8" data-path="../task/聚合api.html">
            
                <a href="../task/聚合api.html">
            
                    
                        <b>1.9.29.8.</b>
                    
                    聚合Api
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.29.9" data-path="../task/资源预留配置.html">
            
                <a href="../task/资源预留配置.html">
            
                    
                        <b>1.9.29.9.</b>
                    
                    资源预留配置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9.30" data-path="../webhook.html">
            
                <a href="../webhook.html">
            
                    
                        <b>1.9.30.</b>
                    
                    Webhook
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.31" data-path="../一致性认证.html">
            
                <a href="../一致性认证.html">
            
                    
                        <b>1.9.31.</b>
                    
                    一致性认证
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.32" data-path="../专利名词.html">
            
                <a href="../专利名词.html">
            
                    
                        <b>1.9.32.</b>
                    
                    专利名词
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.33" data-path="../删除namespace.html">
            
                <a href="../删除namespace.html">
            
                    
                        <b>1.9.33.</b>
                    
                    删除Namespace
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.34" data-path="../简化多集群.html">
            
                <a href="../简化多集群.html">
            
                    
                        <b>1.9.34.</b>
                    
                    简化多集群
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.35" data-path="../网络插件/">
            
                <a href="../网络插件/">
            
                    
                        <b>1.9.35.</b>
                    
                    网络插件
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.35.1" data-path="../网络插件/calico.html">
            
                <a href="../网络插件/calico.html">
            
                    
                        <b>1.9.35.1.</b>
                    
                    Calico
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.35.2" data-path="../网络插件/cilium.html">
            
                <a href="../网络插件/cilium.html">
            
                    
                        <b>1.9.35.2.</b>
                    
                    Cilium
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.35.3" data-path="../网络插件/ebpf.html">
            
                <a href="../网络插件/ebpf.html">
            
                    
                        <b>1.9.35.3.</b>
                    
                    Ebpf
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.35.4" data-path="../网络插件/readme.html">
            
                <a href="../网络插件/readme.html">
            
                    
                        <b>1.9.35.4.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9.36" data-path="../镜像/">
            
                <a href="../镜像/">
            
                    
                        <b>1.9.36.</b>
                    
                    镜像
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.36.1" data-path="../镜像/Containerd Stargz Snapshotter.html">
            
                <a href="../镜像/Containerd Stargz Snapshotter.html">
            
                    
                        <b>1.9.36.1.</b>
                    
                    Containerd Stargz Snapshotter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.36.2" data-path="../镜像/OCI.html">
            
                <a href="../镜像/OCI.html">
            
                    
                        <b>1.9.36.2.</b>
                    
                    OCI
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.36.3" data-path="../镜像/harbor/">
            
                <a href="../镜像/harbor/">
            
                    
                        <b>1.9.36.3.</b>
                    
                    Harbor
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.36.3.1" data-path="../镜像/harbor/readme.html">
            
                <a href="../镜像/harbor/readme.html">
            
                    
                        <b>1.9.36.3.1.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9.36.4" data-path="../镜像/readme.html">
            
                <a href="../镜像/readme.html">
            
                    
                        <b>1.9.36.4.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.36.5" data-path="../镜像/自动构建镜像.html">
            
                <a href="../镜像/自动构建镜像.html">
            
                    
                        <b>1.9.36.5.</b>
                    
                    自动构建镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.36.6" data-path="../镜像/镜像加速方案.html">
            
                <a href="../镜像/镜像加速方案.html">
            
                    
                        <b>1.9.36.6.</b>
                    
                    镜像加速方案
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.36.7" data-path="../镜像/镜像延迟加载技术解析.html">
            
                <a href="../镜像/镜像延迟加载技术解析.html">
            
                    
                        <b>1.9.36.7.</b>
                    
                    镜像延迟加载技术解析
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../../math/">
            
                <a href="../../math/">
            
                    
                        <b>1.10.</b>
                    
                    Math
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../../math/readme.html">
            
                <a href="../../math/readme.html">
            
                    
                        <b>1.10.1.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../../math/泊松分布.html">
            
                <a href="../../math/泊松分布.html">
            
                    
                        <b>1.10.2.</b>
                    
                    泊松分布
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../../效率/">
            
                <a href="../../效率/">
            
                    
                        <b>1.11.</b>
                    
                    效率
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../../效率/cat.html">
            
                <a href="../../效率/cat.html">
            
                    
                        <b>1.11.1.</b>
                    
                    Cat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../../效率/docker volume clean.html">
            
                <a href="../../效率/docker volume clean.html">
            
                    
                        <b>1.11.2.</b>
                    
                    Docker Volume Clean
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../../效率/git book.html">
            
                <a href="../../效率/git book.html">
            
                    
                        <b>1.11.3.</b>
                    
                    Git Book
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../../效率/git.html">
            
                <a href="../../效率/git.html">
            
                    
                        <b>1.11.4.</b>
                    
                    Git
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../../效率/linux command.html">
            
                <a href="../../效率/linux command.html">
            
                    
                        <b>1.11.5.</b>
                    
                    Linux Command
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="../../效率/linux 内核.html">
            
                <a href="../../效率/linux 内核.html">
            
                    
                        <b>1.11.6.</b>
                    
                    Linux 内核
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="../../效率/macos path.html">
            
                <a href="../../效率/macos path.html">
            
                    
                        <b>1.11.7.</b>
                    
                    Macos Path
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="../../效率/nfs.html">
            
                <a href="../../效率/nfs.html">
            
                    
                        <b>1.11.8.</b>
                    
                    Nfs
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="../../效率/nginx.html">
            
                <a href="../../效率/nginx.html">
            
                    
                        <b>1.11.9.</b>
                    
                    Nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="../../效率/nginx2.html">
            
                <a href="../../效率/nginx2.html">
            
                    
                        <b>1.11.10.</b>
                    
                    Nginx2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="../../效率/oauth2.html">
            
                <a href="../../效率/oauth2.html">
            
                    
                        <b>1.11.11.</b>
                    
                    Oauth2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="../../效率/ovftool.html">
            
                <a href="../../效率/ovftool.html">
            
                    
                        <b>1.11.12.</b>
                    
                    Ovftool
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="../../效率/readme.html">
            
                <a href="../../效率/readme.html">
            
                    
                        <b>1.11.13.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="../../效率/sed.html">
            
                <a href="../../效率/sed.html">
            
                    
                        <b>1.11.14.</b>
                    
                    Sed
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="../../效率/shell_judge.html">
            
                <a href="../../效率/shell_judge.html">
            
                    
                        <b>1.11.15.</b>
                    
                    Shell Judge
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.16" data-path="../../效率/sshpass.html">
            
                <a href="../../效率/sshpass.html">
            
                    
                        <b>1.11.16.</b>
                    
                    Sshpass
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.17" data-path="../../效率/telepresence.html">
            
                <a href="../../效率/telepresence.html">
            
                    
                        <b>1.11.17.</b>
                    
                    Telepresence
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.18" data-path="../../效率/typora.html">
            
                <a href="../../效率/typora.html">
            
                    
                        <b>1.11.18.</b>
                    
                    Typora
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.19" data-path="../../效率/url encode.html">
            
                <a href="../../效率/url encode.html">
            
                    
                        <b>1.11.19.</b>
                    
                    Url Encode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.20" data-path="../../效率/vim.html">
            
                <a href="../../效率/vim.html">
            
                    
                        <b>1.11.20.</b>
                    
                    Vim
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.21" data-path="../../效率/yum.html">
            
                <a href="../../效率/yum.html">
            
                    
                        <b>1.11.21.</b>
                    
                    Yum
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.22" data-path="../../效率/内网穿透.html">
            
                <a href="../../效率/内网穿透.html">
            
                    
                        <b>1.11.22.</b>
                    
                    内网穿透
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.23" data-path="../../效率/科学上网.html">
            
                <a href="../../效率/科学上网.html">
            
                    
                        <b>1.11.23.</b>
                    
                    科学上网
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.24" data-path="../../效率/证书制作.html">
            
                <a href="../../效率/证书制作.html">
            
                    
                        <b>1.11.24.</b>
                    
                    证书制作
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" >
            
                <span>
            
                    
                        <b>1.12.</b>
                    
                    杂谈
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../../杂谈/论好文章和烂文章.html">
            
                <a href="../../杂谈/论好文章和烂文章.html">
            
                    
                        <b>1.12.1.</b>
                    
                    论好文章和烂文章
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../../测试/">
            
                <a href="../../测试/">
            
                    
                        <b>1.13.</b>
                    
                    测试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../../测试/ginkgo/">
            
                <a href="../../测试/ginkgo/">
            
                    
                        <b>1.13.1.</b>
                    
                    Ginkgo
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1.1" data-path="../../测试/ginkgo/ginkgo.html">
            
                <a href="../../测试/ginkgo/ginkgo.html">
            
                    
                        <b>1.13.1.1.</b>
                    
                    Ginkgo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.1.2" data-path="../../测试/ginkgo/ginkgo_cmd.html">
            
                <a href="../../测试/ginkgo/ginkgo_cmd.html">
            
                    
                        <b>1.13.1.2.</b>
                    
                    Ginkgo Cmd
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.1.3" data-path="../../测试/ginkgo/readme.html">
            
                <a href="../../测试/ginkgo/readme.html">
            
                    
                        <b>1.13.1.3.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../../测试/golang-test.html">
            
                <a href="../../测试/golang-test.html">
            
                    
                        <b>1.13.2.</b>
                    
                    Golang Test
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../../测试/http测试.html">
            
                <a href="../../测试/http测试.html">
            
                    
                        <b>1.13.3.</b>
                    
                    Http测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../../测试/readme.html">
            
                <a href="../../测试/readme.html">
            
                    
                        <b>1.13.4.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../../测试/其他功能.html">
            
                <a href="../../测试/其他功能.html">
            
                    
                        <b>1.13.5.</b>
                    
                    其他功能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../../测试/单元测试.html">
            
                <a href="../../测试/单元测试.html">
            
                    
                        <b>1.13.6.</b>
                    
                    单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="../../测试/单元测试2.html">
            
                <a href="../../测试/单元测试2.html">
            
                    
                        <b>1.13.7.</b>
                    
                    单元测试2
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="../../测试/基准测试.html">
            
                <a href="../../测试/基准测试.html">
            
                    
                        <b>1.13.8.</b>
                    
                    基准测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.9" data-path="../../测试/子测试与子基准测试.html">
            
                <a href="../../测试/子测试与子基准测试.html">
            
                    
                        <b>1.13.9.</b>
                    
                    子测试与子基准测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.10" data-path="../../测试/并行测试.html">
            
                <a href="../../测试/并行测试.html">
            
                    
                        <b>1.13.10.</b>
                    
                    并行测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.11" data-path="../../测试/质量检查/">
            
                <a href="../../测试/质量检查/">
            
                    
                        <b>1.13.11.</b>
                    
                    质量检查
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.11.1" data-path="../../测试/质量检查/Sonar.html">
            
                <a href="../../测试/质量检查/Sonar.html">
            
                    
                        <b>1.13.11.1.</b>
                    
                    Sonar
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.11.2" data-path="../../测试/质量检查/go_lint.html">
            
                <a href="../../测试/质量检查/go_lint.html">
            
                    
                        <b>1.13.11.2.</b>
                    
                    Go Lint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.11.3" data-path="../../测试/质量检查/readme.html">
            
                <a href="../../测试/质量检查/readme.html">
            
                    
                        <b>1.13.11.3.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../../规范/">
            
                <a href="../../规范/">
            
                    
                        <b>1.14.</b>
                    
                    规范
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../../规范/CodeReviewComments.html">
            
                <a href="../../规范/CodeReviewComments.html">
            
                    
                        <b>1.14.1.</b>
                    
                    CodeReviewComments
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../../规范/git规范.html">
            
                <a href="../../规范/git规范.html">
            
                    
                        <b>1.14.2.</b>
                    
                    Git规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../../规范/golang 代码规范.html">
            
                <a href="../../规范/golang 代码规范.html">
            
                    
                        <b>1.14.3.</b>
                    
                    Golang 代码规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.4" data-path="../../规范/readme.html">
            
                <a href="../../规范/readme.html">
            
                    
                        <b>1.14.4.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.5" data-path="../../规范/代码走读.html">
            
                <a href="../../规范/代码走读.html">
            
                    
                        <b>1.14.5.</b>
                    
                    代码走读
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../../设计模式/">
            
                <a href="../../设计模式/">
            
                    
                        <b>1.15.</b>
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../../设计模式/readme.html">
            
                <a href="../../设计模式/readme.html">
            
                    
                        <b>1.15.1.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../../设计模式/创建模型/">
            
                <a href="../../设计模式/创建模型/">
            
                    
                        <b>1.15.2.</b>
                    
                    创建模型
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.2.1" data-path="../../设计模式/创建模型/readme.html">
            
                <a href="../../设计模式/创建模型/readme.html">
            
                    
                        <b>1.15.2.1.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2.2" data-path="../../设计模式/创建模型/创建者模型.html">
            
                <a href="../../设计模式/创建模型/创建者模型.html">
            
                    
                        <b>1.15.2.2.</b>
                    
                    创建者模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2.3" data-path="../../设计模式/创建模型/单例模式.html">
            
                <a href="../../设计模式/创建模型/单例模式.html">
            
                    
                        <b>1.15.2.3.</b>
                    
                    单例模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2.4" data-path="../../设计模式/创建模型/原型模式.html">
            
                <a href="../../设计模式/创建模型/原型模式.html">
            
                    
                        <b>1.15.2.4.</b>
                    
                    原型模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2.5" data-path="../../设计模式/创建模型/工厂方法.html">
            
                <a href="../../设计模式/创建模型/工厂方法.html">
            
                    
                        <b>1.15.2.5.</b>
                    
                    工厂方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2.6" data-path="../../设计模式/创建模型/抽象工厂.html">
            
                <a href="../../设计模式/创建模型/抽象工厂.html">
            
                    
                        <b>1.15.2.6.</b>
                    
                    抽象工厂
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2.7" data-path="../../设计模式/创建模型/简单工厂.html">
            
                <a href="../../设计模式/创建模型/简单工厂.html">
            
                    
                        <b>1.15.2.7.</b>
                    
                    简单工厂
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../../设计模式/结构型模型/">
            
                <a href="../../设计模式/结构型模型/">
            
                    
                        <b>1.15.3.</b>
                    
                    结构型模型
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.3.1" data-path="../../设计模式/结构型模型/readme.html">
            
                <a href="../../设计模式/结构型模型/readme.html">
            
                    
                        <b>1.15.3.1.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3.2" data-path="../../设计模式/结构型模型/享元模式.html">
            
                <a href="../../设计模式/结构型模型/享元模式.html">
            
                    
                        <b>1.15.3.2.</b>
                    
                    享元模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3.3" data-path="../../设计模式/结构型模型/代理模式.html">
            
                <a href="../../设计模式/结构型模型/代理模式.html">
            
                    
                        <b>1.15.3.3.</b>
                    
                    代理模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3.4" data-path="../../设计模式/结构型模型/外观模式.html">
            
                <a href="../../设计模式/结构型模型/外观模式.html">
            
                    
                        <b>1.15.3.4.</b>
                    
                    外观模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3.5" data-path="../../设计模式/结构型模型/桥模式.html">
            
                <a href="../../设计模式/结构型模型/桥模式.html">
            
                    
                        <b>1.15.3.5.</b>
                    
                    桥模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3.6" data-path="../../设计模式/结构型模型/组合模式.html">
            
                <a href="../../设计模式/结构型模型/组合模式.html">
            
                    
                        <b>1.15.3.6.</b>
                    
                    组合模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3.7" data-path="../../设计模式/结构型模型/装饰模式.html">
            
                <a href="../../设计模式/结构型模型/装饰模式.html">
            
                    
                        <b>1.15.3.7.</b>
                    
                    装饰模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3.8" data-path="../../设计模式/结构型模型/适配器模式.html">
            
                <a href="../../设计模式/结构型模型/适配器模式.html">
            
                    
                        <b>1.15.3.8.</b>
                    
                    适配器模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../../设计模式/行为型模型/">
            
                <a href="../../设计模式/行为型模型/">
            
                    
                        <b>1.15.4.</b>
                    
                    行为型模型
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.4.1" data-path="../../设计模式/行为型模型/readme.html">
            
                <a href="../../设计模式/行为型模型/readme.html">
            
                    
                        <b>1.15.4.1.</b>
                    
                    Readme
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.2" data-path="../../设计模式/行为型模型/中介者模式.html">
            
                <a href="../../设计模式/行为型模型/中介者模式.html">
            
                    
                        <b>1.15.4.2.</b>
                    
                    中介者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.3" data-path="../../设计模式/行为型模型/命令模式.html">
            
                <a href="../../设计模式/行为型模型/命令模式.html">
            
                    
                        <b>1.15.4.3.</b>
                    
                    命令模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.4" data-path="../../设计模式/行为型模型/备忘录模式.html">
            
                <a href="../../设计模式/行为型模型/备忘录模式.html">
            
                    
                        <b>1.15.4.4.</b>
                    
                    备忘录模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.5" data-path="../../设计模式/行为型模型/模板方法模式.html">
            
                <a href="../../设计模式/行为型模型/模板方法模式.html">
            
                    
                        <b>1.15.4.5.</b>
                    
                    模板方法模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.6" data-path="../../设计模式/行为型模型/状态模式.html">
            
                <a href="../../设计模式/行为型模型/状态模式.html">
            
                    
                        <b>1.15.4.6.</b>
                    
                    状态模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.7" data-path="../../设计模式/行为型模型/策略模式.html">
            
                <a href="../../设计模式/行为型模型/策略模式.html">
            
                    
                        <b>1.15.4.7.</b>
                    
                    策略模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.8" data-path="../../设计模式/行为型模型/职责链模式.html">
            
                <a href="../../设计模式/行为型模型/职责链模式.html">
            
                    
                        <b>1.15.4.8.</b>
                    
                    职责链模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.9" data-path="../../设计模式/行为型模型/观察者模式.html">
            
                <a href="../../设计模式/行为型模型/观察者模式.html">
            
                    
                        <b>1.15.4.9.</b>
                    
                    观察者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.10" data-path="../../设计模式/行为型模型/解释器模式.html">
            
                <a href="../../设计模式/行为型模型/解释器模式.html">
            
                    
                        <b>1.15.4.10.</b>
                    
                    解释器模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.11" data-path="../../设计模式/行为型模型/访问者模式.html">
            
                <a href="../../设计模式/行为型模型/访问者模式.html">
            
                    
                        <b>1.15.4.11.</b>
                    
                    访问者模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4.12" data-path="../../设计模式/行为型模型/迭代器模式.html">
            
                <a href="../../设计模式/行为型模型/迭代器模式.html">
            
                    
                        <b>1.15.4.12.</b>
                    
                    迭代器模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../.." >Scheme</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-anchor"></i><ul><li><a href="#k8s-client-and-scheme">k8s client and scheme</a></li><ul><li><a href="#1-&#x4EC0;&#x4E48;&#x662F;scheme">1. &#x4EC0;&#x4E48;&#x662F;scheme</a></li><ul><li><a href="#11-&#x5728;&#x4E86;&#x89E3;scheme&#x4E4B;&#x524D;&#xFF0C;-&#x6211;&#x4EEC;&#x5148;&#x4E86;&#x89E3;&#x4E0B;kubernetes-&#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x5206;&#x7C7B;">1.1 &#x5728;&#x4E86;&#x89E3;scheme&#x4E4B;&#x524D;&#xFF0C; &#x6211;&#x4EEC;&#x5148;&#x4E86;&#x89E3;&#x4E0B;kubernetes &#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x5206;&#x7C7B;</a></li><li><a href="#12-scheme-&#x662F;&#x4EC0;&#x4E48;">1.2 scheme &#x662F;&#x4EC0;&#x4E48;</a></li><li><a href="#13-&#x7531;&#x8868;&#x53CA;&#x91CC;scheme&#x7ED3;&#x6784;&#x4F53;&#x5B9A;&#x4E49;">1.3 &#x7531;&#x8868;&#x53CA;&#x91CC;,scheme&#x7ED3;&#x6784;&#x4F53;&#x5B9A;&#x4E49;</a></li></ul><li><a href="#2-&#x5982;&#x4F55;&#x4F7F;&#x7528;scheme">2. &#x5982;&#x4F55;&#x4F7F;&#x7528;scheme</a></li><ul><li><a href="#21-&#x5B9A;&#x4E49;&#x6CE8;&#x518C;&#x65B9;&#x6CD5;-addtoscheme">2.1 &#x5B9A;&#x4E49;&#x6CE8;&#x518C;&#x65B9;&#x6CD5; AddToScheme</a></li><li><a href="#22-&#x8C03;&#x7528;addtoscheme&#x8FDB;&#x884C;gvk&#x6CE8;&#x518C;">2.2 &#x8C03;&#x7528;AddToScheme&#x8FDB;&#x884C;GVK&#x6CE8;&#x518C;</a></li><li><a href="#23-docode">2.3 docode</a></li></ul><li><a href="#3-kubectl-&#x662F;&#x5982;&#x4F55;&#x5C06;&#x8F93;&#x5165;&#x5B57;&#x8282;&#x8F6C;&#x6362;&#x6210;k8s&#x5BF9;&#x8C61;&#x7684;">3. kubectl &#x662F;&#x5982;&#x4F55;&#x5C06;&#x8F93;&#x5165;&#x5B57;&#x8282;&#x8F6C;&#x6362;&#x6210;k8s&#x5BF9;&#x8C61;&#x7684;</a></li><ul><li><a href="#31-visitor-&#x63A5;&#x53E3;">3.1 visitor &#x63A5;&#x53E3;</a></li><li><a href="#32-streamvisitor">3.2 StreamVisitor</a></li><li><a href="#33-&#x65B9;&#x6CD5;infofordata&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;">3.3 &#x65B9;&#x6CD5;infoForData&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;</a></li></ul><li><a href="#4-&#x4EE3;&#x7801;&#x5B9E;&#x8DF5;">4. &#x4EE3;&#x7801;&#x5B9E;&#x8DF5;</a></li></ul></ul></div><a href="#k8s-client-and-scheme" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="k8s-client-and-scheme"><a name="k8s-client-and-scheme" class="anchor-navigation-ex-anchor" href="#k8s-client-and-scheme"><i class="fa fa-link" aria-hidden="true"></i></a>k8s client and scheme</h1>
<!-- toc -->
<ul>
<li><a href="#1-%E4%BB%80%E4%B9%88%E6%98%AFscheme">1. &#x4EC0;&#x4E48;&#x662F;scheme</a><ul>
<li><a href="#11-%E5%9C%A8%E4%BA%86%E8%A7%A3scheme%E4%B9%8B%E5%89%8D-%E6%88%91%E4%BB%AC%E5%85%88%E4%BA%86%E8%A7%A3%E4%B8%8Bkubernetes-%E4%B8%AD%E7%9A%84%E8%B5%84%E6%BA%90%E5%88%86%E7%B1%BB">1.1 &#x5728;&#x4E86;&#x89E3;scheme&#x4E4B;&#x524D;&#xFF0C; &#x6211;&#x4EEC;&#x5148;&#x4E86;&#x89E3;&#x4E0B;kubernetes &#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x5206;&#x7C7B;</a></li>
<li><a href="#12-scheme-%E6%98%AF%E4%BB%80%E4%B9%88">1.2 scheme &#x662F;&#x4EC0;&#x4E48;</a></li>
<li><a href="#13-%E7%94%B1%E8%A1%A8%E5%8F%8A%E9%87%8Cscheme%E7%BB%93%E6%9E%84%E4%BD%93%E5%AE%9A%E4%B9%89">1.3 &#x7531;&#x8868;&#x53CA;&#x91CC;,scheme&#x7ED3;&#x6784;&#x4F53;&#x5B9A;&#x4E49;</a></li>
</ul>
</li>
<li><a href="#2-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8scheme">2. &#x5982;&#x4F55;&#x4F7F;&#x7528;scheme</a><ul>
<li><a href="#21-%E5%AE%9A%E4%B9%89%E6%B3%A8%E5%86%8C%E6%96%B9%E6%B3%95-addtoscheme">2.1 &#x5B9A;&#x4E49;&#x6CE8;&#x518C;&#x65B9;&#x6CD5; AddToScheme</a></li>
<li><a href="#22-%E8%B0%83%E7%94%A8addtoscheme%E8%BF%9B%E8%A1%8Cgvk%E6%B3%A8%E5%86%8C">2.2 &#x8C03;&#x7528;AddToScheme&#x8FDB;&#x884C;GVK&#x6CE8;&#x518C;</a></li>
<li><a href="#23-docode">2.3 docode</a></li>
</ul>
</li>
<li><a href="#3-kubectl-%E6%98%AF%E5%A6%82%E4%BD%95%E5%B0%86%E8%BE%93%E5%85%A5%E5%AD%97%E8%8A%82%E8%BD%AC%E6%8D%A2%E6%88%90k8s%E5%AF%B9%E8%B1%A1%E7%9A%84">3. kubectl &#x662F;&#x5982;&#x4F55;&#x5C06;&#x8F93;&#x5165;&#x5B57;&#x8282;&#x8F6C;&#x6362;&#x6210;k8s&#x5BF9;&#x8C61;&#x7684;</a><ul>
<li><a href="#31-visitor-%E6%8E%A5%E5%8F%A3">3.1 visitor &#x63A5;&#x53E3;</a></li>
<li><a href="#32-streamvisitor">3.2 StreamVisitor</a></li>
<li><a href="#33-%E6%96%B9%E6%B3%95infofordata%E7%9A%84%E5%85%B7%E4%BD%93%E5%AE%9E%E7%8E%B0">3.3 &#x65B9;&#x6CD5;infoForData&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;</a></li>
</ul>
</li>
<li><a href="#4-%E4%BB%A3%E7%A0%81%E5%AE%9E%E8%B7%B5">4. &#x4EE3;&#x7801;&#x5B9E;&#x8DF5;</a></li>
</ul>
<!-- tocstop -->
<h2 id="1-&#x4EC0;&#x4E48;&#x662F;scheme"><a name="1-&#x4EC0;&#x4E48;&#x662F;scheme" class="anchor-navigation-ex-anchor" href="#1-&#x4EC0;&#x4E48;&#x662F;scheme"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x4EC0;&#x4E48;&#x662F;scheme</h2>
<h3 id="11-&#x5728;&#x4E86;&#x89E3;scheme&#x4E4B;&#x524D;&#xFF0C;-&#x6211;&#x4EEC;&#x5148;&#x4E86;&#x89E3;&#x4E0B;kubernetes-&#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x5206;&#x7C7B;"><a name="11-&#x5728;&#x4E86;&#x89E3;scheme&#x4E4B;&#x524D;&#xFF0C;-&#x6211;&#x4EEC;&#x5148;&#x4E86;&#x89E3;&#x4E0B;kubernetes-&#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x5206;&#x7C7B;" class="anchor-navigation-ex-anchor" href="#11-&#x5728;&#x4E86;&#x89E3;scheme&#x4E4B;&#x524D;&#xFF0C;-&#x6211;&#x4EEC;&#x5148;&#x4E86;&#x89E3;&#x4E0B;kubernetes-&#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x5206;&#x7C7B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1 &#x5728;&#x4E86;&#x89E3;scheme&#x4E4B;&#x524D;&#xFF0C; &#x6211;&#x4EEC;&#x5148;&#x4E86;&#x89E3;&#x4E0B;kubernetes &#x4E2D;&#x7684;&#x8D44;&#x6E90;&#x5206;&#x7C7B;</h3>
<p>&#x8FD0;&#x7EF4;&#x4EBA;&#x5458;&#x5728;&#x521B;&#x5EFA;&#x8D44;&#x6E90;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x80FD;&#x53EA;&#x5173;&#x6CE8;kind&#xFF08;&#x5982;deployment&#xFF0C;&#x672C;&#x80FD;&#x7684;&#x5FFD;&#x7565;&#x5206;&#x7EC4;&#x548C;&#x7248;&#x672C;&#x4FE1;&#x606F;&#xFF09;&#xFF0C; &#x4F46;&#x662F;&#x5728;k8s&#x7684;&#x8D44;&#x6E90;&#x5B9A;&#x4F4D;&#x4E2D;&#x53EA;&#x8BF4;deployment&#x662F;&#x4E0D;&#x51C6;&#x786E;&#x7684;&#x3002;&#x56E0;&#x4E3A;Kubernetes&#x7CFB;&#x7EDF;&#x652F;&#x6301;&#x591A;&#x4E2A;Group&#xFF0C;&#x6BCF;&#x4E2A;Group&#x652F;&#x6301;&#x591A;&#x4E2A;Version&#xFF0C;&#x6BCF;&#x4E2A;Version&#x652F;&#x6301;&#x591A;&#x4E2A;Resource&#xFF0C;&#x5176;&#x4E2D;&#x90E8;&#x5206;&#x8D44;&#x6E90;&#x540C;&#x65F6;&#x4F1A;&#x62E5;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x5B50;&#x8D44;&#x6E90;&#xFF08;&#x5373;SubResource&#xFF09;&#x3002;&#x4F8B;&#x5982;&#xFF0C;Deployment&#x8D44;&#x6E90;&#x62E5;&#x6709;Status&#x5B50;&#x8D44;&#x6E90;&#x3002;</p>
<p>&#x8D44;&#x6E90;&#x7EC4;&#x3001;&#x8D44;&#x6E90;&#x7248;&#x672C;&#x3001;&#x8D44;&#x6E90;&#x3001;&#x5B50;&#x8D44;&#x6E90;&#x7684;&#x5B8C;&#x6574;&#x8868;&#x73B0;&#x5F62;&#x5F0F;&#x4E3A;<group>/<version>/<resource>/<subresource>&#x3002;&#x4EE5;&#x5E38;&#x7528;&#x7684;Deployment&#x8D44;&#x6E90;&#x4E3A;&#x4F8B;&#xFF0C;&#x5176;&#x5B8C;&#x6574;&#x8868;&#x73B0;&#x5F62;&#x5F0F;&#x4E3A;apps/v1/deployments/status&#x3002;</subresource></resource></version></group></p>
<p>&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x8D44;&#x6E90;&#x7BA1;&#x7406;&#x548C;&#x6709;&#x5E8F;&#x8FED;&#x4EE3;&#xFF0C;&#x8D44;&#x6E90;&#x6709;Group&#xFF08;&#x7EC4;&#xFF09;&#x548C;Version&#xFF08;&#x7248;&#x672C;&#xFF09;&#x7684;&#x6982;&#x5FF5;&#x3002;</p>
<p>&#x200B;    &#x25CF; Group&#xFF1A;&#x88AB;&#x79F0;&#x4E3A;&#x8D44;&#x6E90;&#x7EC4;&#xFF0C;&#x5728;Kubernetes API Server&#x4E2D;&#x4E5F;&#x53EF;&#x79F0;&#x5176;&#x4E3A;APIGroup&#x3002;</p>
<p>&#x200B;    &#x25CF; Version&#xFF1A;&#x88AB;&#x79F0;&#x4E3A;&#x8D44;&#x6E90;&#x7248;&#x672C;&#xFF0C;&#x5728;Kubernetes API Server&#x4E2D;&#x4E5F;&#x53EF;&#x79F0;&#x5176;&#x4E3A;APIVersions&#x3002;</p>
<p>&#x200B;    &#x25CF; Resource&#xFF1A;&#x88AB;&#x79F0;&#x4E3A;&#x8D44;&#x6E90;&#xFF0C;&#x5728;Kubernetes API Server&#x4E2D;&#x4E5F;&#x53EF;&#x79F0;&#x5176;&#x4E3A;APIResource&#x3002;</p>
<p>&#x200B;    &#x25CF; Kind&#xFF1A;&#x8D44;&#x6E90;&#x79CD;&#x7C7B;&#xFF0C;&#x63CF;&#x8FF0;Resource&#x7684;&#x79CD;&#x7C7B;&#xFF0C;&#x4E0E;Resource&#x4E3A;&#x540C;&#x4E00;&#x7EA7;&#x522B;&#x3002;</p>
<p><img src="https://cai-hello-1253732611.cos.ap-shanghai.myqcloud.com/share/032231.png" alt="image-20210518112228962"></p>
<h3 id="12-scheme-&#x662F;&#x4EC0;&#x4E48;"><a name="12-scheme-&#x662F;&#x4EC0;&#x4E48;" class="anchor-navigation-ex-anchor" href="#12-scheme-&#x662F;&#x4EC0;&#x4E48;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2 scheme &#x662F;&#x4EC0;&#x4E48;</h3>
<p>Kubernetes&#x7CFB;&#x7EDF;&#x62E5;&#x6709;&#x4F17;&#x591A;&#x8D44;&#x6E90;&#xFF0C;&#x6BCF;&#x4E00;&#x79CD;&#x8D44;&#x6E90;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF0C;&#x8FD9;&#x4E9B;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x9700;&#x8981;&#x6709;&#x7EDF;&#x4E00;&#x7684;&#x6CE8;&#x518C;&#x3001;&#x5B58;&#x50A8;&#x3001;&#x67E5;&#x8BE2;&#x3001;&#x7BA1;&#x7406;&#x7B49;&#x673A;&#x5236;&#x3002;&#x76EE;&#x524D;Kubernetes&#x7CFB;&#x7EDF;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x90FD;&#x5DF2;&#x6CE8;&#x518C;&#x5230;Scheme&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x4E2D;&#xFF0C;&#x5176;&#x662F;&#x4E00;&#x4E2A;&#x5185;&#x5B58;&#x578B;&#x7684;&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#xFF0C;&#x62E5;&#x6709;&#x5982;&#x4E0B;&#x7279;&#x70B9;&#x3002;</p>
<p>&#x200B;    &#x25CF; &#x652F;&#x6301;&#x6CE8;&#x518C;&#x591A;&#x79CD;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF0C;&#x5305;&#x62EC;&#x5185;&#x90E8;&#x7248;&#x672C;&#x548C;&#x5916;&#x90E8;&#x7248;&#x672C;&#x3002;</p>
<p>&#x200B;    &#x25CF; &#x652F;&#x6301;&#x591A;&#x79CD;&#x7248;&#x672C;&#x8F6C;&#x6362;&#x673A;&#x5236;&#x3002;</p>
<p>&#x200B;    &#x25CF; &#x652F;&#x6301;&#x4E0D;&#x540C;&#x8D44;&#x6E90;&#x7684;&#x5E8F;&#x5217;&#x5316;/&#x53CD;&#x5E8F;&#x5217;&#x5316;&#x673A;&#x5236;&#x3002;</p>
<p>Scheme&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x652F;&#x6301;&#x4E24;&#x79CD;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF08;Type&#xFF09;&#x7684;&#x6CE8;&#x518C;&#xFF0C;&#x5206;&#x522B;&#x662F;<strong>UnversionedType</strong>&#x548C;<strong>KnownType</strong>&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF0C;&#x5206;&#x522B;&#x4ECB;&#x7ECD;&#x5982;&#x4E0B;&#x3002;</p>
<p>&#x200B;    &#x25CF; <strong>UnversionedType</strong>&#xFF1A;&#x65E0;&#x7248;&#x672C;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF0C;&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x65E9;&#x671F;Kubernetes&#x7CFB;&#x7EDF;&#x4E2D;&#x7684;&#x6982;&#x5FF5;&#xFF0C;&#x5B83;&#x4E3B;&#x8981;&#x5E94;&#x7528;&#x4E8E;&#x67D0;&#x4E9B;&#x6CA1;&#x6709;&#x7248;&#x672C;&#x7684;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF0C;&#x8BE5;&#x7C7B;&#x578B;&#x7684;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x5E76;&#x4E0D;&#x9700;&#x8981;&#x8FDB;&#x884C;&#x8F6C;&#x6362;&#x3002;&#x5728;&#x76EE;&#x524D;&#x7684;Kubernetes&#x53D1;&#x884C;&#x7248;&#x672C;&#x4E2D;&#xFF0C;&#x65E0;&#x7248;&#x672C;&#x7C7B;&#x578B;&#x5DF2;&#x88AB;&#x5F31;&#x5316;&#xFF0C;&#x51E0;&#x4E4E;&#x6240;&#x6709;&#x7684;&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x90FD;&#x62E5;&#x6709;&#x7248;&#x672C;&#xFF0C;&#x4F46;&#x5728;metav1&#x5143;&#x6570;&#x636E;&#x4E2D;&#x8FD8;&#x6709;&#x90E8;&#x5206;&#x7C7B;&#x578B;&#xFF0C;&#x5B83;&#x4EEC;&#x65E2;&#x5C5E;&#x4E8E;meta.k8s.io/v1&#x53C8;&#x5C5E;&#x4E8E;UnversionedType&#x65E0;&#x7248;&#x672C;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF0C;&#x4F8B;&#x5982;metav1.Status&#x3001;metav1.APIVersions&#x3001;metav1.APIGroupList&#x3001;metav1.APIGroup&#x3001;metav1.APIResourceList&#x3002;</p>
<p>&#x200B;    &#x25CF; <strong>KnownType</strong>&#xFF1A;&#x662F;&#x76EE;&#x524D;Kubernetes&#x6700;&#x5E38;&#x7528;&#x7684;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#xFF0C;&#x4E5F;&#x53EF;&#x79F0;&#x5176;&#x4E3A;&#x201C;&#x62E5;&#x6709;&#x7248;&#x672C;&#x7684;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x201D;&#x3002;&#x5728;Scheme&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x4E2D;&#xFF0C;UnversionedType&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8C61;&#x901A;&#x8FC7;scheme.AddUnversionedTypes&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x6CE8;&#x518C;&#xFF0C;KnownType&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8C61;&#x901A;&#x8FC7;scheme.AddKnownTypes&#x65B9;&#x6CD5;&#x8FDB;&#x884C;&#x6CE8;&#x518C;&#x3002;</p>
<h3 id="13-&#x7531;&#x8868;&#x53CA;&#x91CC;scheme&#x7ED3;&#x6784;&#x4F53;&#x5B9A;&#x4E49;"><a name="13-&#x7531;&#x8868;&#x53CA;&#x91CC;scheme&#x7ED3;&#x6784;&#x4F53;&#x5B9A;&#x4E49;" class="anchor-navigation-ex-anchor" href="#13-&#x7531;&#x8868;&#x53CA;&#x91CC;scheme&#x7ED3;&#x6784;&#x4F53;&#x5B9A;&#x4E49;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3 &#x7531;&#x8868;&#x53CA;&#x91CC;,scheme&#x7ED3;&#x6784;&#x4F53;&#x5B9A;&#x4E49;</h3>
<p>staging/src/k8s.io/apimachinery/pkg/runtime/scheme.go</p>
<pre class="language-"><code class="lang-go"><span class="token keyword">type</span> Scheme <span class="token keyword">struct</span> <span class="token punctuation">{</span>
    gvkToType <span class="token keyword">map</span><span class="token punctuation">[</span>schema<span class="token punctuation">.</span>GroupVersionKind<span class="token punctuation">]</span>reflect<span class="token punctuation">.</span>Type
    typeToGVK <span class="token keyword">map</span><span class="token punctuation">[</span>reflect<span class="token punctuation">.</span>Type<span class="token punctuation">]</span><span class="token punctuation">[</span><span class="token punctuation">]</span>schema<span class="token punctuation">.</span>GroupVersionKind
    unversionedTypes <span class="token keyword">map</span><span class="token punctuation">[</span>reflect<span class="token punctuation">.</span>Type<span class="token punctuation">]</span>schema<span class="token punctuation">.</span>GroupVersionKind
    unversionedKinds <span class="token keyword">map</span><span class="token punctuation">[</span><span class="token builtin">string</span><span class="token punctuation">]</span>reflect<span class="token punctuation">.</span>Type
    <span class="token operator">...</span>
<span class="token punctuation">}</span>
</code></pre>
<p>Scheme&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x7ED3;&#x6784;&#x5B57;&#x6BB5;&#x8BF4;&#x660E;&#x5982;&#x4E0B;&#x3002;</p>
<p>&#x200B;    &#x25CF; gvkToType&#xFF1A;&#x5B58;&#x50A8;GVK&#x4E0E;Type&#x7684;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#x3002;</p>
<p>&#x200B;    &#x25CF; typeToGVK&#xFF1A;&#x5B58;&#x50A8;Type&#x4E0E;GVK&#x7684;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#xFF0C;&#x4E00;&#x4E2A;Type&#x4F1A;&#x5BF9;&#x5E94;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;GVK&#x3002;</p>
<p>&#x200B;    &#x25CF; unversionedTypes&#xFF1A;&#x5B58;&#x50A8;UnversionedType&#x4E0E;GVK&#x7684;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#x3002;</p>
<p>&#x200B;    &#x25CF; unversionedKinds&#xFF1A;&#x5B58;&#x50A8;Kind&#xFF08;&#x8D44;&#x6E90;&#x79CD;&#x7C7B;&#xFF09;&#x540D;&#x79F0;&#x4E0E;UnversionedType&#x7684;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#x3002;</p>
<p>Scheme&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x901A;&#x8FC7;Go&#x8BED;&#x8A00;&#x7684;map&#x7ED3;&#x6784;&#x5B9E;&#x73B0;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#xFF0C;&#x8FD9;&#x4E9B;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;&#x9AD8;&#x6548;&#x7684;&#x6B63;&#x5411;&#x548C;&#x53CD;&#x5411;&#x68C0;&#x7D22;&#xFF0C;&#x4ECE;Scheme&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x4E2D;&#x68C0;&#x7D22;&#x67D0;&#x4E2A;GVK&#x7684;Type&#xFF0C;&#x5B83;&#x7684;&#x65F6;&#x95F4;&#x590D;&#x6742;&#x5EA6;&#x4E3A;O&#xFF08;1&#xFF09;&#x3002;&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#x5982;&#x4E0B;&#x56FE;&#xFF1A;</p>
<p><img src="https://cai-hello-1253732611.cos.ap-shanghai.myqcloud.com/share/033030.png" alt="image-20210518113028732"></p>
<h2 id="2-&#x5982;&#x4F55;&#x4F7F;&#x7528;scheme"><a name="2-&#x5982;&#x4F55;&#x4F7F;&#x7528;scheme" class="anchor-navigation-ex-anchor" href="#2-&#x5982;&#x4F55;&#x4F7F;&#x7528;scheme"><i class="fa fa-link" aria-hidden="true"></i></a>2. &#x5982;&#x4F55;&#x4F7F;&#x7528;scheme</h2>
<h3 id="21-&#x5B9A;&#x4E49;&#x6CE8;&#x518C;&#x65B9;&#x6CD5;-addtoscheme"><a name="21-&#x5B9A;&#x4E49;&#x6CE8;&#x518C;&#x65B9;&#x6CD5;-addtoscheme" class="anchor-navigation-ex-anchor" href="#21-&#x5B9A;&#x4E49;&#x6CE8;&#x518C;&#x65B9;&#x6CD5;-addtoscheme"><i class="fa fa-link" aria-hidden="true"></i></a>2.1 &#x5B9A;&#x4E49;&#x6CE8;&#x518C;&#x65B9;&#x6CD5; AddToScheme</h3>
<p>&#x901A;&#x8FC7;runtime.NewScheme&#x5B9E;&#x4F8B;&#x5316;&#x4E00;&#x4E2A;&#x65B0;&#x7684;Scheme&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x3002;&#x6CE8;&#x518C;&#x8D44;&#x6E90;&#x7C7B;&#x578B;&#x5230;Scheme&#x8D44;&#x6E90;&#x6CE8;&#x518C;&#x8868;&#x6709;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#xFF0C;</p>
<ul>
<li><p>&#x7B2C;&#x4E00;&#x79CD;&#x901A;&#x8FC7;scheme.AddKnownTypes&#x65B9;&#x6CD5;&#x6CE8;&#x518C;KnownType&#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8C61;</p>
</li>
<li><p>&#x7B2C;&#x4E8C;&#x79CD;&#x901A;&#x8FC7;scheme.AddUnversionedTypes&#x65B9;&#x6CD5;&#x6CE8;&#x518C;UnversionedType&#x7C7B;&#x578B;&#x7684;&#x5BF9;&#x8C61;</p>
</li>
</ul>
<p>&#x5728;&#x6211;&#x4EEC;&#x521B;&#x5EFA;crd &#x8D44;&#x6E90;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x901A;&#x8FC7;&#x4EE3;&#x7801;&#x751F;&#x6210;&#x5DE5;&#x5177;&#xFF0C;&#x90FD;&#x4F1A;&#x5728;register.go&#x6587;&#x4EF6;&#x91CC;&#x5E2E;&#x6211;&#x4EEC;&#x81EA;&#x52A8;&#x751F;&#x6210; AddToScheme&#x65B9;&#x6CD5;</p>
<pre class="language-"><code class="lang-go"><span class="token keyword">package</span> v1

<span class="token keyword">import</span> <span class="token punctuation">(</span>
    metav1 <span class="token string">&quot;k8s.io/apimachinery/pkg/apis/meta/v1&quot;</span>
    <span class="token string">&quot;k8s.io/apimachinery/pkg/runtime&quot;</span>
    <span class="token string">&quot;k8s.io/apimachinery/pkg/runtime/schema&quot;</span>
    <span class="token string">&quot;lsh-mcp-lcs-timer/constant&quot;</span>
<span class="token punctuation">)</span>

<span class="token keyword">var</span> <span class="token punctuation">(</span>
    SchemeBuilder <span class="token operator">=</span> runtime<span class="token punctuation">.</span><span class="token function">NewSchemeBuilder</span><span class="token punctuation">(</span>addKnownTypes<span class="token punctuation">)</span>

  <span class="token comment">// &#x5916;&#x90E8;&#x7684;scheme &#x76F4;&#x63A5;&#x8C03;&#x7528;&#x8BE5;&#x65B9;&#x6CD5;&#x8FDB;&#x884C;scheme&#x6CE8;&#x518C;</span>
    AddToScheme <span class="token operator">=</span> SchemeBuilder<span class="token punctuation">.</span>AddToScheme
    SchemeGroupVersion <span class="token operator">=</span> schema<span class="token punctuation">.</span>GroupVersion<span class="token punctuation">{</span>Group<span class="token punctuation">:</span> constant<span class="token punctuation">.</span>ResourceOverviewGroupName<span class="token punctuation">,</span> Version<span class="token punctuation">:</span> <span class="token string">&quot;v1&quot;</span><span class="token punctuation">}</span>
<span class="token punctuation">)</span>

<span class="token keyword">func</span> <span class="token function">Kind</span><span class="token punctuation">(</span>kind <span class="token builtin">string</span><span class="token punctuation">)</span> schema<span class="token punctuation">.</span>GroupKind <span class="token punctuation">{</span>
    <span class="token keyword">return</span> SchemeGroupVersion<span class="token punctuation">.</span><span class="token function">WithKind</span><span class="token punctuation">(</span>kind<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">GroupKind</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>

<span class="token keyword">func</span> <span class="token function">Resource</span><span class="token punctuation">(</span>resource <span class="token builtin">string</span><span class="token punctuation">)</span> schema<span class="token punctuation">.</span>GroupResource <span class="token punctuation">{</span>
    <span class="token keyword">return</span> SchemeGroupVersion<span class="token punctuation">.</span><span class="token function">WithResource</span><span class="token punctuation">(</span>resource<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">GroupResource</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>

<span class="token keyword">func</span> <span class="token function">addKnownTypes</span><span class="token punctuation">(</span>scheme <span class="token operator">*</span>runtime<span class="token punctuation">.</span>Scheme<span class="token punctuation">)</span> <span class="token builtin">error</span> <span class="token punctuation">{</span>
    scheme<span class="token punctuation">.</span><span class="token function">AddKnownTypes</span><span class="token punctuation">(</span>SchemeGroupVersion<span class="token punctuation">,</span>
        <span class="token operator">&amp;</span>RsOverView<span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token operator">&amp;</span>RsOverViewList<span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">)</span>
    metav1<span class="token punctuation">.</span><span class="token function">AddToGroupVersion</span><span class="token punctuation">(</span>scheme<span class="token punctuation">,</span> SchemeGroupVersion<span class="token punctuation">)</span>
    <span class="token keyword">return</span> <span class="token boolean">nil</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="22-&#x8C03;&#x7528;addtoscheme&#x8FDB;&#x884C;gvk&#x6CE8;&#x518C;"><a name="22-&#x8C03;&#x7528;addtoscheme&#x8FDB;&#x884C;gvk&#x6CE8;&#x518C;" class="anchor-navigation-ex-anchor" href="#22-&#x8C03;&#x7528;addtoscheme&#x8FDB;&#x884C;gvk&#x6CE8;&#x518C;"><i class="fa fa-link" aria-hidden="true"></i></a>2.2 &#x8C03;&#x7528;AddToScheme&#x8FDB;&#x884C;GVK&#x6CE8;&#x518C;</h3>
<p>&#x573A;&#x666F;&#xFF1A; &#x5C06;&#x5176;&#x4ED6;&#x9879;&#x76EE;&#x7684;GVK &#x6CE8;&#x518C;&#x5230;&#x81EA;&#x5DF1;&#x9879;&#x76EE;&#x7684;scheme&#x4E2D;&#x3002;</p>
<p>example&#xFF0C;&#x4E0B;&#x9762;&#x4EE3;&#x7801;&#x6458;&#x81EA;kubevela&#xFF1A; </p>
<pre class="language-"><code class="lang-go"><span class="token keyword">import</span><span class="token punctuation">(</span>
    kruise <span class="token string">&quot;github.com/openkruise/kruise-api/apps/v1alpha1&quot;</span>
    certmanager <span class="token string">&quot;github.com/wonderflow/cert-manager-api/pkg/apis/certmanager/v1&quot;</span>
    istioclientv1beta1 <span class="token string">&quot;istio.io/client-go/pkg/apis/networking/v1beta1&quot;</span>
    crdv1 <span class="token string">&quot;k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1&quot;</span>
    k8sruntime <span class="token string">&quot;k8s.io/apimachinery/pkg/runtime&quot;</span>
    clientgoscheme <span class="token string">&quot;k8s.io/client-go/kubernetes/scheme&quot;</span>


    oamcore <span class="token string">&quot;github.com/oam-dev/kubevela/apis/core.oam.dev&quot;</span>
    oamstandard <span class="token string">&quot;github.com/oam-dev/kubevela/apis/standard.oam.dev/v1alpha1&quot;</span>

<span class="token punctuation">)</span>

<span class="token keyword">var</span> <span class="token punctuation">(</span>
    <span class="token comment">// Scheme defines the default KubeVela schema</span>
    Scheme <span class="token operator">=</span> k8sruntime<span class="token punctuation">.</span><span class="token function">NewScheme</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span>

<span class="token keyword">func</span> <span class="token function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token boolean">_</span> <span class="token operator">=</span> clientgoscheme<span class="token punctuation">.</span><span class="token function">AddToScheme</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span>
    <span class="token boolean">_</span> <span class="token operator">=</span> crdv1<span class="token punctuation">.</span><span class="token function">AddToScheme</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span>
    <span class="token boolean">_</span> <span class="token operator">=</span> oamcore<span class="token punctuation">.</span><span class="token function">AddToScheme</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span>
    <span class="token boolean">_</span> <span class="token operator">=</span> oamstandard<span class="token punctuation">.</span><span class="token function">AddToScheme</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span>
    <span class="token boolean">_</span> <span class="token operator">=</span> istioclientv1beta1<span class="token punctuation">.</span><span class="token function">AddToScheme</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span>
    <span class="token boolean">_</span> <span class="token operator">=</span> certmanager<span class="token punctuation">.</span><span class="token function">AddToScheme</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span>
    <span class="token boolean">_</span> <span class="token operator">=</span> kruise<span class="token punctuation">.</span><span class="token function">AddToScheme</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span>
    <span class="token comment">// +kubebuilder:scaffold:scheme</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="23-docode"><a name="23-docode" class="anchor-navigation-ex-anchor" href="#23-docode"><i class="fa fa-link" aria-hidden="true"></i></a>2.3 docode</h3>
<p>&#x8FD9;&#x91CC;&#x4EE5; k8s.io/client-go &#x4E3A;&#x4F8B;&#xFF0C; &#x4EE3;&#x7801;&#x4F4D;&#x7F6E;&#xFF1A; kubernetes/scheme/register.go    </p>
<p>&#x6CE8;&#x518C;scheme</p>
<pre class="language-"><code class="lang-go"><span class="token keyword">var</span> Scheme <span class="token operator">=</span> runtime<span class="token punctuation">.</span><span class="token function">NewScheme</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">var</span> Codecs <span class="token operator">=</span> serializer<span class="token punctuation">.</span><span class="token function">NewCodecFactory</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span> 
<span class="token keyword">var</span> ParameterCodec <span class="token operator">=</span> runtime<span class="token punctuation">.</span><span class="token function">NewParameterCodec</span><span class="token punctuation">(</span>Scheme<span class="token punctuation">)</span>

<span class="token comment">// &#x751F;&#x6210;&#x4E00;&#x4E2A;Decode</span>
<span class="token keyword">var</span> decode <span class="token operator">=</span> Codecs<span class="token punctuation">.</span><span class="token function">UniversalDeserializer</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>Decode
</code></pre>
<p>UniversalDeserializer &#x8FD4;&#x56DE; CodeFactory &#x7684;&#x5C5E;&#x6027;universal</p>
<pre class="language-"><code>// UniversalDeserializer can convert any stored data recognized by this factory into a Go object that satisfies
// runtime.Object. It does not perform conversion. It does not perform defaulting.
func (f CodecFactory) UniversalDeserializer() runtime.Decoder {
    return f.universal
}
</code></pre><p>&#x67E5;&#x770B;CodecFactory&#x751F;&#x6210;&#x8FC7;&#x7A0B;&#xFF0C;&#x53D1;&#x73B0;universal &#x7684;&#x503C;&#x662F;recognizer.NewDecoder(decoders...)</p>
<pre class="language-"><code class="lang-go"><span class="token keyword">func</span> <span class="token function">NewCodecFactory</span><span class="token punctuation">(</span>scheme <span class="token operator">*</span>runtime<span class="token punctuation">.</span>Scheme<span class="token punctuation">,</span> mutators <span class="token operator">...</span>CodecFactoryOptionsMutator<span class="token punctuation">)</span> CodecFactory <span class="token punctuation">{</span>
    options <span class="token operator">:=</span> CodecFactoryOptions<span class="token punctuation">{</span>Pretty<span class="token punctuation">:</span> <span class="token boolean">true</span><span class="token punctuation">}</span>
    <span class="token keyword">for</span> <span class="token boolean">_</span><span class="token punctuation">,</span> fn <span class="token operator">:=</span> <span class="token keyword">range</span> mutators <span class="token punctuation">{</span>
        <span class="token function">fn</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>options<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

    serializers <span class="token operator">:=</span> <span class="token function">newSerializersForScheme</span><span class="token punctuation">(</span>scheme<span class="token punctuation">,</span> json<span class="token punctuation">.</span>DefaultMetaFactory<span class="token punctuation">,</span> options<span class="token punctuation">)</span>
    <span class="token keyword">return</span> <span class="token function">newCodecFactory</span><span class="token punctuation">(</span>scheme<span class="token punctuation">,</span> serializers<span class="token punctuation">)</span>
<span class="token punctuation">}</span>

<span class="token comment">// newCodecFactory is a helper for testing that allows a different metafactory to be specified.</span>
<span class="token keyword">func</span> <span class="token function">newCodecFactory</span><span class="token punctuation">(</span>scheme <span class="token operator">*</span>runtime<span class="token punctuation">.</span>Scheme<span class="token punctuation">,</span> serializers <span class="token punctuation">[</span><span class="token punctuation">]</span>serializerType<span class="token punctuation">)</span> CodecFactory <span class="token punctuation">{</span>
    decoders <span class="token operator">:=</span> <span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span>runtime<span class="token punctuation">.</span>Decoder<span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token function">len</span><span class="token punctuation">(</span>serializers<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token keyword">var</span> accepts <span class="token punctuation">[</span><span class="token punctuation">]</span>runtime<span class="token punctuation">.</span>SerializerInfo
    alreadyAccepted <span class="token operator">:=</span> <span class="token function">make</span><span class="token punctuation">(</span><span class="token keyword">map</span><span class="token punctuation">[</span><span class="token builtin">string</span><span class="token punctuation">]</span><span class="token keyword">struct</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>

    <span class="token keyword">var</span> legacySerializer runtime<span class="token punctuation">.</span>Serializer
    <span class="token keyword">for</span> <span class="token boolean">_</span><span class="token punctuation">,</span> d <span class="token operator">:=</span> <span class="token keyword">range</span> serializers <span class="token punctuation">{</span>
        <span class="token comment">// &#x7EC4;&#x88C5;decoder</span>
        decoders <span class="token operator">=</span> <span class="token function">append</span><span class="token punctuation">(</span>decoders<span class="token punctuation">,</span> d<span class="token punctuation">.</span>Serializer<span class="token punctuation">)</span>
        <span class="token operator">...</span><span class="token punctuation">.</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> legacySerializer <span class="token operator">==</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        legacySerializer <span class="token operator">=</span> serializers<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>Serializer
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> CodecFactory<span class="token punctuation">{</span>
        scheme<span class="token punctuation">:</span>      scheme<span class="token punctuation">,</span>
        serializers<span class="token punctuation">:</span> serializers<span class="token punctuation">,</span>

        <span class="token comment">// set universal</span>
        universal<span class="token punctuation">:</span>   recognizer<span class="token punctuation">.</span><span class="token function">NewDecoder</span><span class="token punctuation">(</span>decoders<span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">,</span>

        accepts<span class="token punctuation">:</span> accepts<span class="token punctuation">,</span>

        legacySerializer<span class="token punctuation">:</span> legacySerializer<span class="token punctuation">,</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x7ED3;&#x8BBA;&#xFF1A;universal &#x662F;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#xFF0C; &#x91CC;&#x9762;&#x7684;&#x5143;&#x7D20;&#x90FD;&#x5B9E;&#x73B0;&#x4E86;&#x63A5;&#x53E3; Decoder</p>
<pre class="language-"><code class="lang-go"><span class="token comment">// NewDecoder creates a decoder that will attempt multiple decoders in an order defined</span>
<span class="token comment">// by:</span>
<span class="token comment">//</span>
<span class="token comment">// 1. The decoder implements RecognizingDecoder and identifies the data</span>
<span class="token comment">// 2. All other decoders, and any decoder that returned true for unknown.</span>
<span class="token comment">//</span>
<span class="token comment">// The order passed to the constructor is preserved within those priorities.</span>
<span class="token keyword">func</span> <span class="token function">NewDecoder</span><span class="token punctuation">(</span>decoders <span class="token operator">...</span>runtime<span class="token punctuation">.</span>Decoder<span class="token punctuation">)</span> runtime<span class="token punctuation">.</span>Decoder <span class="token punctuation">{</span>
   <span class="token keyword">return</span> <span class="token operator">&amp;</span>decoder<span class="token punctuation">{</span>
      decoders<span class="token punctuation">:</span> decoders<span class="token punctuation">,</span>
   <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p><strong>&#x8C03;&#x7528;Decoder &#x7684; decode &#x65B9;&#x6CD5;</strong></p>
<pre class="language-"><code class="lang-go">obj<span class="token punctuation">,</span> <span class="token boolean">_</span><span class="token punctuation">,</span> err <span class="token operator">:=</span> <span class="token function">decode</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token function">byte</span><span class="token punctuation">(</span>objStr<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token boolean">nil</span><span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">)</span>
</code></pre>
<p>decoders &#x5173;&#x4E8E;Decode &#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#xFF0C; &#x4EE3;&#x7801;&#xFF1A;k8s.io/apimachinery@v0.20.1/pkg/runtime/serializer/recognizer/recognizer.go</p>
<pre class="language-"><code class="lang-go"><span class="token keyword">func</span> <span class="token punctuation">(</span>d <span class="token operator">*</span>decoder<span class="token punctuation">)</span> <span class="token function">Decode</span><span class="token punctuation">(</span>data <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">,</span> gvk <span class="token operator">*</span>schema<span class="token punctuation">.</span>GroupVersionKind<span class="token punctuation">,</span> into runtime<span class="token punctuation">.</span>Object<span class="token punctuation">)</span> <span class="token punctuation">(</span>runtime<span class="token punctuation">.</span>Object<span class="token punctuation">,</span> <span class="token operator">*</span>schema<span class="token punctuation">.</span>GroupVersionKind<span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">var</span> <span class="token punctuation">(</span>
        lastErr <span class="token builtin">error</span>
        skipped <span class="token punctuation">[</span><span class="token punctuation">]</span>runtime<span class="token punctuation">.</span>Decoder
    <span class="token punctuation">)</span>

    <span class="token comment">// try recognizers, record any decoders we need to give a chance later</span>
    <span class="token keyword">for</span> <span class="token boolean">_</span><span class="token punctuation">,</span> r <span class="token operator">:=</span> <span class="token keyword">range</span> d<span class="token punctuation">.</span>decoders <span class="token punctuation">{</span>
        <span class="token keyword">switch</span> t <span class="token operator">:=</span> r<span class="token punctuation">.</span><span class="token punctuation">(</span><span class="token keyword">type</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">case</span> RecognizingDecoder<span class="token punctuation">:</span>
            buf <span class="token operator">:=</span> bytes<span class="token punctuation">.</span><span class="token function">NewBuffer</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span>
            ok<span class="token punctuation">,</span> unknown<span class="token punctuation">,</span> err <span class="token operator">:=</span> t<span class="token punctuation">.</span><span class="token function">RecognizesData</span><span class="token punctuation">(</span>buf<span class="token punctuation">)</span>
            <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
                lastErr <span class="token operator">=</span> err
                <span class="token keyword">continue</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">if</span> unknown <span class="token punctuation">{</span>
                skipped <span class="token operator">=</span> <span class="token function">append</span><span class="token punctuation">(</span>skipped<span class="token punctuation">,</span> t<span class="token punctuation">)</span>
                <span class="token keyword">continue</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">if</span> <span class="token operator">!</span>ok <span class="token punctuation">{</span>
                <span class="token keyword">continue</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> r<span class="token punctuation">.</span><span class="token function">Decode</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> gvk<span class="token punctuation">,</span> into<span class="token punctuation">)</span>
        <span class="token keyword">default</span><span class="token punctuation">:</span>
            skipped <span class="token operator">=</span> <span class="token function">append</span><span class="token punctuation">(</span>skipped<span class="token punctuation">,</span> t<span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// try recognizers that returned unknown or didn&apos;t recognize their data</span>
    <span class="token keyword">for</span> <span class="token boolean">_</span><span class="token punctuation">,</span> r <span class="token operator">:=</span> <span class="token keyword">range</span> skipped <span class="token punctuation">{</span>
        out<span class="token punctuation">,</span> actual<span class="token punctuation">,</span> err <span class="token operator">:=</span> r<span class="token punctuation">.</span><span class="token function">Decode</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> gvk<span class="token punctuation">,</span> into<span class="token punctuation">)</span>
        <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            lastErr <span class="token operator">=</span> err
            <span class="token keyword">continue</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> out<span class="token punctuation">,</span> actual<span class="token punctuation">,</span> <span class="token boolean">nil</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span> lastErr <span class="token operator">==</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        lastErr <span class="token operator">=</span> fmt<span class="token punctuation">.</span><span class="token function">Errorf</span><span class="token punctuation">(</span><span class="token string">&quot;no serialization format matched the provided data&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> lastErr
<span class="token punctuation">}</span>
</code></pre>
<p>&#x6316;&#x6398;Decoder&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x7C7B;&#xFF1A;</p>
<p>&#x67E5;&#x770B;CodeFactory &#x76F8;&#x5173;&#x4EE3;&#x7801;&#xFF0C;&#x53D1;&#x73B0;&#x8FD9;&#x91CC;Decoder&#x7684;&#x5B9E;&#x73B0;&#x7C7B;&#x662F;Serializer</p>
<pre class="language-"><code class="lang-go"><span class="token comment">// form. If typer is not nil, the object has the group, version, and kind fields set. Options are copied into the Serializer</span>
<span class="token comment">// and are immutable.</span>
<span class="token keyword">func</span> <span class="token function">NewSerializerWithOptions</span><span class="token punctuation">(</span>meta MetaFactory<span class="token punctuation">,</span> creater runtime<span class="token punctuation">.</span>ObjectCreater<span class="token punctuation">,</span> typer runtime<span class="token punctuation">.</span>ObjectTyper<span class="token punctuation">,</span> options SerializerOptions<span class="token punctuation">)</span> <span class="token operator">*</span>Serializer <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token operator">&amp;</span>Serializer<span class="token punctuation">{</span>
        meta<span class="token punctuation">:</span>       meta<span class="token punctuation">,</span>
        creater<span class="token punctuation">:</span>    creater<span class="token punctuation">,</span>
        typer<span class="token punctuation">:</span>      typer<span class="token punctuation">,</span>
        options<span class="token punctuation">:</span>    options<span class="token punctuation">,</span>
        identifier<span class="token punctuation">:</span> <span class="token function">identifier</span><span class="token punctuation">(</span>options<span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>Serializer &#x7C7B;&#x7684;Docder &#x63A5;&#x53E3;&#x5B9E;&#x73B0;</p>
<pre class="language-"><code class="lang-go"><span class="token comment">// Decode attempts to convert the provided data into YAML or JSON, extract the stored schema kind, apply the provided default gvk, and then</span>
<span class="token comment">// load that data into an object matching the desired schema kind or the provided into.</span>
<span class="token comment">// If into is *runtime.Unknown, the raw data will be extracted and no decoding will be performed.</span>
<span class="token comment">// If into is not registered with the typer, then the object will be straight decoded using normal JSON/YAML unmarshalling.</span>
<span class="token comment">// If into is provided and the original data is not fully qualified with kind/version/group, the type of the into will be used to alter the returned gvk.</span>
<span class="token comment">// If into is nil or data&apos;s gvk different from into&apos;s gvk, it will generate a new Object with ObjectCreater.New(gvk)</span>
<span class="token comment">// On success or most errors, the method will return the calculated schema kind.</span>
<span class="token comment">// The gvk calculate priority will be originalData &gt; default gvk &gt; into</span>
<span class="token keyword">func</span> <span class="token punctuation">(</span>s <span class="token operator">*</span>Serializer<span class="token punctuation">)</span> <span class="token function">Decode</span><span class="token punctuation">(</span>originalData <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">,</span> gvk <span class="token operator">*</span>schema<span class="token punctuation">.</span>GroupVersionKind<span class="token punctuation">,</span> into runtime<span class="token punctuation">.</span>Object<span class="token punctuation">)</span> <span class="token punctuation">(</span>runtime<span class="token punctuation">.</span>Object<span class="token punctuation">,</span> <span class="token operator">*</span>schema<span class="token punctuation">.</span>GroupVersionKind<span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    data <span class="token operator">:=</span> originalData
    <span class="token keyword">if</span> s<span class="token punctuation">.</span>options<span class="token punctuation">.</span>Yaml <span class="token punctuation">{</span>
        altered<span class="token punctuation">,</span> err <span class="token operator">:=</span> yaml<span class="token punctuation">.</span><span class="token function">YAMLToJSON</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span>
        <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
        <span class="token punctuation">}</span>
        data <span class="token operator">=</span> altered
    <span class="token punctuation">}</span>

    actual<span class="token punctuation">,</span> err <span class="token operator">:=</span> s<span class="token punctuation">.</span>meta<span class="token punctuation">.</span><span class="token function">Interpret</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span> gvk <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token operator">*</span>actual <span class="token operator">=</span> <span class="token function">gvkWithDefaults</span><span class="token punctuation">(</span><span class="token operator">*</span>actual<span class="token punctuation">,</span> <span class="token operator">*</span>gvk<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span> unk<span class="token punctuation">,</span> ok <span class="token operator">:=</span> into<span class="token punctuation">.</span><span class="token punctuation">(</span><span class="token operator">*</span>runtime<span class="token punctuation">.</span>Unknown<span class="token punctuation">)</span><span class="token punctuation">;</span> ok <span class="token operator">&amp;&amp;</span> unk <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        unk<span class="token punctuation">.</span>Raw <span class="token operator">=</span> originalData
        unk<span class="token punctuation">.</span>ContentType <span class="token operator">=</span> runtime<span class="token punctuation">.</span>ContentTypeJSON
        unk<span class="token punctuation">.</span><span class="token function">GetObjectKind</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">SetGroupVersionKind</span><span class="token punctuation">(</span><span class="token operator">*</span>actual<span class="token punctuation">)</span>
        <span class="token keyword">return</span> unk<span class="token punctuation">,</span> actual<span class="token punctuation">,</span> <span class="token boolean">nil</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span> into <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token boolean">_</span><span class="token punctuation">,</span> isUnstructured <span class="token operator">:=</span> into<span class="token punctuation">.</span><span class="token punctuation">(</span>runtime<span class="token punctuation">.</span>Unstructured<span class="token punctuation">)</span>
        types<span class="token punctuation">,</span> <span class="token boolean">_</span><span class="token punctuation">,</span> err <span class="token operator">:=</span> s<span class="token punctuation">.</span>typer<span class="token punctuation">.</span><span class="token function">ObjectKinds</span><span class="token punctuation">(</span>into<span class="token punctuation">)</span>
        <span class="token keyword">switch</span> <span class="token punctuation">{</span>
        <span class="token keyword">case</span> runtime<span class="token punctuation">.</span><span class="token function">IsNotRegisteredError</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span><span class="token punctuation">,</span> isUnstructured<span class="token punctuation">:</span>
            <span class="token keyword">if</span> err <span class="token operator">:=</span> caseSensitiveJsonIterator<span class="token punctuation">.</span><span class="token function">Unmarshal</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> into<span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
                <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> actual<span class="token punctuation">,</span> err
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> into<span class="token punctuation">,</span> actual<span class="token punctuation">,</span> <span class="token boolean">nil</span>
        <span class="token keyword">case</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span><span class="token punctuation">:</span>
            <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> actual<span class="token punctuation">,</span> err
        <span class="token keyword">default</span><span class="token punctuation">:</span>
            <span class="token operator">*</span>actual <span class="token operator">=</span> <span class="token function">gvkWithDefaults</span><span class="token punctuation">(</span><span class="token operator">*</span>actual<span class="token punctuation">,</span> types<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">if</span> <span class="token function">len</span><span class="token punctuation">(</span>actual<span class="token punctuation">.</span>Kind<span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> actual<span class="token punctuation">,</span> runtime<span class="token punctuation">.</span><span class="token function">NewMissingKindErr</span><span class="token punctuation">(</span><span class="token function">string</span><span class="token punctuation">(</span>originalData<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> <span class="token function">len</span><span class="token punctuation">(</span>actual<span class="token punctuation">.</span>Version<span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> actual<span class="token punctuation">,</span> runtime<span class="token punctuation">.</span><span class="token function">NewMissingVersionErr</span><span class="token punctuation">(</span><span class="token function">string</span><span class="token punctuation">(</span>originalData<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>


    <span class="token comment">// use the target if necessary, &#x91CD;&#x70B9;&#xFF1A; &#x751F;&#x6210;&#x4E00;&#x4E2A;&#x7A7A;&#x6570;&#x636E;&#x7684;&#x5BF9;&#x8C61;</span>
    obj<span class="token punctuation">,</span> err <span class="token operator">:=</span> runtime<span class="token punctuation">.</span><span class="token function">UseOrCreateObject</span><span class="token punctuation">(</span>s<span class="token punctuation">.</span>typer<span class="token punctuation">,</span> s<span class="token punctuation">.</span>creater<span class="token punctuation">,</span> <span class="token operator">*</span>actual<span class="token punctuation">,</span> into<span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> actual<span class="token punctuation">,</span> err
    <span class="token punctuation">}</span>

   <span class="token comment">// &#x901A;&#x8FC7; json &#x89E3;&#x6790;&#xFF0C;&#x7ED9;&#x4E0A;&#x9762;&#x751F;&#x6210;&#x7684;&#x7A7A;&#x6570;&#x636E;&#x5BF9;&#x8C61;&#xFF0C;&#x8D4B;&#x503C;</span>
    <span class="token keyword">if</span> err <span class="token operator">:=</span> caseSensitiveJsonIterator<span class="token punctuation">.</span><span class="token function">Unmarshal</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> obj<span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> actual<span class="token punctuation">,</span> err
    <span class="token punctuation">}</span>

    <span class="token comment">// If the deserializer is non-strict, return successfully here.</span>
    <span class="token keyword">if</span> <span class="token operator">!</span>s<span class="token punctuation">.</span>options<span class="token punctuation">.</span>Strict <span class="token punctuation">{</span>
        <span class="token keyword">return</span> obj<span class="token punctuation">,</span> actual<span class="token punctuation">,</span> <span class="token boolean">nil</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// In strict mode pass the data trough the YAMLToJSONStrict converter.</span>
    <span class="token comment">// This is done to catch duplicate fields regardless of encoding (JSON or YAML). For JSON data,</span>
    <span class="token comment">// the output would equal the input, unless there is a parsing error such as duplicate fields.</span>
    <span class="token comment">// As we know this was successful in the non-strict case, the only error that may be returned here</span>
    <span class="token comment">// is because of the newly-added strictness. hence we know we can return the typed strictDecoderError</span>
    <span class="token comment">// the actual error is that the object contains duplicate fields.</span>
    altered<span class="token punctuation">,</span> err <span class="token operator">:=</span> yaml<span class="token punctuation">.</span><span class="token function">YAMLToJSONStrict</span><span class="token punctuation">(</span>originalData<span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> actual<span class="token punctuation">,</span> runtime<span class="token punctuation">.</span><span class="token function">NewStrictDecodingError</span><span class="token punctuation">(</span>err<span class="token punctuation">.</span><span class="token function">Error</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">string</span><span class="token punctuation">(</span>originalData<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// As performance is not an issue for now for the strict deserializer (one has regardless to do</span>
    <span class="token comment">// the unmarshal twice), we take the sanitized, altered data that is guaranteed to have no duplicated</span>
    <span class="token comment">// fields, and unmarshal this into a copy of the already-populated obj. Any error that occurs here is</span>
    <span class="token comment">// due to that a matching field doesn&apos;t exist in the object. hence we can return a typed strictDecoderError,</span>
    <span class="token comment">// the actual error is that the object contains unknown field.</span>
    strictObj <span class="token operator">:=</span> obj<span class="token punctuation">.</span><span class="token function">DeepCopyObject</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">:=</span> strictCaseSensitiveJsonIterator<span class="token punctuation">.</span><span class="token function">Unmarshal</span><span class="token punctuation">(</span>altered<span class="token punctuation">,</span> strictObj<span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> actual<span class="token punctuation">,</span> runtime<span class="token punctuation">.</span><span class="token function">NewStrictDecodingError</span><span class="token punctuation">(</span>err<span class="token punctuation">.</span><span class="token function">Error</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">string</span><span class="token punctuation">(</span>originalData<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token comment">// Always return the same object as the non-strict serializer to avoid any deviations.</span>
    <span class="token keyword">return</span> obj<span class="token punctuation">,</span> actual<span class="token punctuation">,</span> <span class="token boolean">nil</span>
<span class="token punctuation">}</span>
</code></pre>
<h2 id="3-kubectl-&#x662F;&#x5982;&#x4F55;&#x5C06;&#x8F93;&#x5165;&#x5B57;&#x8282;&#x8F6C;&#x6362;&#x6210;k8s&#x5BF9;&#x8C61;&#x7684;"><a name="3-kubectl-&#x662F;&#x5982;&#x4F55;&#x5C06;&#x8F93;&#x5165;&#x5B57;&#x8282;&#x8F6C;&#x6362;&#x6210;k8s&#x5BF9;&#x8C61;&#x7684;" class="anchor-navigation-ex-anchor" href="#3-kubectl-&#x662F;&#x5982;&#x4F55;&#x5C06;&#x8F93;&#x5165;&#x5B57;&#x8282;&#x8F6C;&#x6362;&#x6210;k8s&#x5BF9;&#x8C61;&#x7684;"><i class="fa fa-link" aria-hidden="true"></i></a>3. kubectl &#x662F;&#x5982;&#x4F55;&#x5C06;&#x8F93;&#x5165;&#x5B57;&#x8282;&#x8F6C;&#x6362;&#x6210;k8s&#x5BF9;&#x8C61;&#x7684;</h2>
<h3 id="31-visitor-&#x63A5;&#x53E3;"><a name="31-visitor-&#x63A5;&#x53E3;" class="anchor-navigation-ex-anchor" href="#31-visitor-&#x63A5;&#x53E3;"><i class="fa fa-link" aria-hidden="true"></i></a>3.1 visitor &#x63A5;&#x53E3;</h3>
<p>Visitor&#x63A5;&#x53E3;&#x5305;&#x542B;Visit&#x65B9;&#x6CD5;&#xFF0C;&#x5B9E;&#x73B0;&#x4E86;Visit&#xFF08;VisitorFunc&#xFF09; error&#x7684;&#x7ED3;&#x6784;&#x4F53;&#x90FD;&#x53EF;&#x4EE5;&#x6210;&#x4E3A;Visitor&#x3002;&#x5176;&#x4E2D;&#xFF0C;VisitorFunc&#x662F;&#x4E00;&#x4E2A;&#x533F;&#x540D;&#x51FD;&#x6570;&#xFF0C;&#x5B83;&#x63A5;&#x6536;Info&#x4E0E;error&#x4FE1;&#x606F;&#xFF0C;Info&#x7ED3;&#x6784;&#x7528;&#x4E8E;&#x5B58;&#x50A8;RESTClient&#x8BF7;&#x6C42;&#x7684;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#xFF0C;&#x800C;VisitorFunc&#x533F;&#x540D;&#x51FD;&#x6570;&#x5219;&#x751F;&#x6210;&#x6216;&#x5904;&#x7406;Info&#x7ED3;&#x6784;&#x3002;Visitor&#x7684;&#x8BBE;&#x8BA1;&#x8F83;&#x4E3A;&#x590D;&#x6742;&#xFF0C;&#x5E76;&#x975E;&#x5355;&#x7EAF;&#x5B9E;&#x73B0;&#x4E86;&#x8BBF;&#x95EE;&#x8005;&#x6A21;&#x5F0F;&#xFF0C;&#x5B83;&#x76F8;&#x5F53;&#x4E8E;&#x4E00;&#x4E2A;&#x533F;&#x540D;&#x51FD;&#x6570;&#x96C6;&#x3002;&#x5728;Kubernetes&#x6E90;&#x7801;&#x4E2D;&#xFF0C;Visitor&#x88AB;&#x8BBE;&#x8BA1;&#x4E3A;&#x53EF;&#x4EE5;&#x591A;&#x5C42;&#x5D4C;&#x5957;&#xFF08;&#x5373;&#x591A;&#x5C42;&#x533F;&#x540D;&#x51FD;&#x6570;&#x5D4C;&#x5957;&#xFF0C;&#x4F7F;&#x7528;&#x4E00;&#x4E2A;Visitor&#x5D4C;&#x5957;&#x53E6;&#x4E00;&#x4E2A;Visitor&#xFF09;</p>
<pre class="language-"><code class="lang-go"><span class="token comment">// Visitor lets clients walk a list of resources.</span>
<span class="token keyword">type</span> Visitor <span class="token keyword">interface</span> <span class="token punctuation">{</span>
    <span class="token function">Visit</span><span class="token punctuation">(</span>VisitorFunc<span class="token punctuation">)</span> <span class="token builtin">error</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="32-streamvisitor"><a name="32-streamvisitor" class="anchor-navigation-ex-anchor" href="#32-streamvisitor"><i class="fa fa-link" aria-hidden="true"></i></a>3.2 StreamVisitor</h3>
<p>kubectl &#x5C06;&#x8F93;&#x5165;&#x7684;&#x5B57;&#x8282;&#x7801;&#x901A;&#x8FC7;&#x5982;&#x4E0B;visitor&#x8FDB;&#x884C;&#x5904;&#x7406;</p>
<p>DecoratedVisitor&#x2192;ContinueOnErrorVisitor &#x2192; FlattenListVisitor &#x2192;FlattenListVisitor &#x2192; <strong>StreamVisitor</strong> &#x2192;FileVisitor&#x2192;EagerVisitorList</p>
<p>&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x91CD;&#x70B9;&#x5173;&#x6CE8;StreamVisitor&#x7684;&#x64CD;&#x4F5C;</p>
<pre class="language-"><code class="lang-go"><span class="token comment">// Visit implements Visitor over a stream. StreamVisitor is able to distinct multiple resources in one stream.</span>
<span class="token keyword">func</span> <span class="token punctuation">(</span>v <span class="token operator">*</span>StreamVisitor<span class="token punctuation">)</span> <span class="token function">Visit</span><span class="token punctuation">(</span>fn VisitorFunc<span class="token punctuation">)</span> <span class="token builtin">error</span> <span class="token punctuation">{</span>
    d <span class="token operator">:=</span> yaml<span class="token punctuation">.</span><span class="token function">NewYAMLOrJSONDecoder</span><span class="token punctuation">(</span>v<span class="token punctuation">.</span>Reader<span class="token punctuation">,</span> <span class="token number">4096</span><span class="token punctuation">)</span>
    <span class="token keyword">for</span> <span class="token punctuation">{</span>
        ext <span class="token operator">:=</span> runtime<span class="token punctuation">.</span>RawExtension<span class="token punctuation">{</span><span class="token punctuation">}</span>
    <span class="token comment">// &#x4F7F;&#x7528;unstructured.UnstructuredJSONScheme &#x89E3;&#x6790;</span>
    <span class="token comment">// d &#x5FAA;&#x73AF;&#x89E3;&#x6790;&#xFF0C;&#x81EA;&#x52A8;&#x901A;&#x8FC7;---&#x5206;&#x5272;&#x5BF9;&#x8C61;&#xFF0C;&#x6BCF;&#x6B21;&#x53EA;&#x89E3;&#x6790;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;</span>
        <span class="token keyword">if</span> err <span class="token operator">:=</span> d<span class="token punctuation">.</span><span class="token function">Decode</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>ext<span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> err <span class="token operator">==</span> io<span class="token punctuation">.</span>EOF <span class="token punctuation">{</span>
                <span class="token keyword">return</span> <span class="token boolean">nil</span>
            <span class="token punctuation">}</span>
            <span class="token keyword">return</span> fmt<span class="token punctuation">.</span><span class="token function">Errorf</span><span class="token punctuation">(</span><span class="token string">&quot;error parsing %s: %v&quot;</span><span class="token punctuation">,</span> v<span class="token punctuation">.</span>Source<span class="token punctuation">,</span> err<span class="token punctuation">)</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// TODO: This needs to be able to handle object in other encodings and schemas.</span>
        ext<span class="token punctuation">.</span>Raw <span class="token operator">=</span> bytes<span class="token punctuation">.</span><span class="token function">TrimSpace</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">)</span>
        <span class="token keyword">if</span> <span class="token function">len</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span> <span class="token operator">||</span> bytes<span class="token punctuation">.</span><span class="token function">Equal</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token function">byte</span><span class="token punctuation">(</span><span class="token string">&quot;null&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">continue</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> err <span class="token operator">:=</span> <span class="token function">ValidateSchema</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">,</span> v<span class="token punctuation">.</span>Schema<span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> fmt<span class="token punctuation">.</span><span class="token function">Errorf</span><span class="token punctuation">(</span><span class="token string">&quot;error validating %q: %v&quot;</span><span class="token punctuation">,</span> v<span class="token punctuation">.</span>Source<span class="token punctuation">,</span> err<span class="token punctuation">)</span>
        <span class="token punctuation">}</span>

    <span class="token comment">// StreamVisitor &#x5BF9;NewYAMLOrJSONDecoder &#x89E3;&#x6790;&#x51FA;&#x7684;&#x6570;&#x636E;&#x8FDB;&#x4E00;&#x6B65; &#x89E3;&#x7801;&#x51FA;k8s&#x5BF9;&#x8C61;</span>
    <span class="token comment">// info &#x5C31;&#x662F;&#x4E00;&#x4E2A;k8s runtime.Object</span>
        info<span class="token punctuation">,</span> err <span class="token operator">:=</span> v<span class="token punctuation">.</span><span class="token function">infoForData</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">,</span> v<span class="token punctuation">.</span>Source<span class="token punctuation">)</span>
        <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> fnErr <span class="token operator">:=</span> <span class="token function">fn</span><span class="token punctuation">(</span>info<span class="token punctuation">,</span> err<span class="token punctuation">)</span><span class="token punctuation">;</span> fnErr <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
                <span class="token keyword">return</span> fnErr
            <span class="token punctuation">}</span>
            <span class="token keyword">continue</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> err <span class="token operator">:=</span> <span class="token function">fn</span><span class="token punctuation">(</span>info<span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> err
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h3 id="33-&#x65B9;&#x6CD5;infofordata&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;"><a name="33-&#x65B9;&#x6CD5;infofordata&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;" class="anchor-navigation-ex-anchor" href="#33-&#x65B9;&#x6CD5;infofordata&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;"><i class="fa fa-link" aria-hidden="true"></i></a>3.3 &#x65B9;&#x6CD5;infoForData&#x7684;&#x5177;&#x4F53;&#x5B9E;&#x73B0;</h3>
<p>infoForData &#x5C5E;&#x4E8E;StreamVisitor &#x5185;&#x5D4C;&#x7ED3;&#x6784;&#x4F53; mapper&#x7684;&#x65B9;&#x6CD5;&#xFF0C; &#x6240;&#x4EE5;&#x4E0A;&#x9762;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x901A;&#x8FC7;StreamVisitor&#x8C03;&#x7528;infoForData&#x65B9;&#x6CD5;</p>
<pre class="language-"><code class="lang-go"><span class="token comment">// Mapper is a convenience struct for holding references to the interfaces</span>
<span class="token comment">// needed to create Info for arbitrary objects.</span>
<span class="token keyword">type</span> mapper <span class="token keyword">struct</span> <span class="token punctuation">{</span>
    <span class="token comment">// localFn indicates the call can&apos;t make server requests</span>
    localFn <span class="token keyword">func</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token builtin">bool</span>

    restMapperFn RESTMapperFunc
    clientFn     <span class="token keyword">func</span><span class="token punctuation">(</span>version schema<span class="token punctuation">.</span>GroupVersion<span class="token punctuation">)</span> <span class="token punctuation">(</span>RESTClient<span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span>
    decoder      runtime<span class="token punctuation">.</span>Decoder
<span class="token punctuation">}</span>
</code></pre>
<pre class="language-"><code class="lang-go">
<span class="token keyword">func</span> <span class="token punctuation">(</span>m <span class="token operator">*</span>mapper<span class="token punctuation">)</span> <span class="token function">infoForData</span><span class="token punctuation">(</span>data <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">,</span> source <span class="token builtin">string</span><span class="token punctuation">)</span> <span class="token punctuation">(</span><span class="token operator">*</span>Info<span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>

  <span class="token comment">// &#x5BF9;&#x5B57;&#x8282;&#x6570;&#x7EC4;&#x8FDB;&#x884C;&#x89E3;&#x7801;</span>
    obj<span class="token punctuation">,</span> gvk<span class="token punctuation">,</span> err <span class="token operator">:=</span> m<span class="token punctuation">.</span>decoder<span class="token punctuation">.</span><span class="token function">Decode</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> fmt<span class="token punctuation">.</span><span class="token function">Errorf</span><span class="token punctuation">(</span><span class="token string">&quot;unable to decode %q: %v&quot;</span><span class="token punctuation">,</span> source<span class="token punctuation">,</span> err<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

    name<span class="token punctuation">,</span> <span class="token boolean">_</span> <span class="token operator">:=</span> metadataAccessor<span class="token punctuation">.</span><span class="token function">Name</span><span class="token punctuation">(</span>obj<span class="token punctuation">)</span>
    namespace<span class="token punctuation">,</span> <span class="token boolean">_</span> <span class="token operator">:=</span> metadataAccessor<span class="token punctuation">.</span><span class="token function">Namespace</span><span class="token punctuation">(</span>obj<span class="token punctuation">)</span>
    resourceVersion<span class="token punctuation">,</span> <span class="token boolean">_</span> <span class="token operator">:=</span> metadataAccessor<span class="token punctuation">.</span><span class="token function">ResourceVersion</span><span class="token punctuation">(</span>obj<span class="token punctuation">)</span>

    ret <span class="token operator">:=</span> <span class="token operator">&amp;</span>Info<span class="token punctuation">{</span>
        Source<span class="token punctuation">:</span>          source<span class="token punctuation">,</span>
        Namespace<span class="token punctuation">:</span>       namespace<span class="token punctuation">,</span>
        Name<span class="token punctuation">:</span>            name<span class="token punctuation">,</span>
        ResourceVersion<span class="token punctuation">:</span> resourceVersion<span class="token punctuation">,</span>

        Object<span class="token punctuation">:</span> obj<span class="token punctuation">,</span>
    <span class="token punctuation">}</span>
  <span class="token operator">...</span> 

    <span class="token keyword">return</span> ret<span class="token punctuation">,</span> <span class="token boolean">nil</span>
<span class="token punctuation">}</span>
</code></pre>
<h2 id="4-&#x4EE3;&#x7801;&#x5B9E;&#x8DF5;"><a name="4-&#x4EE3;&#x7801;&#x5B9E;&#x8DF5;" class="anchor-navigation-ex-anchor" href="#4-&#x4EE3;&#x7801;&#x5B9E;&#x8DF5;"><i class="fa fa-link" aria-hidden="true"></i></a>4. &#x4EE3;&#x7801;&#x5B9E;&#x8DF5;</h2>
<p>&#x76EE;&#x6807;&#xFF1A;</p>
<ol>
<li>&#x5B9E;&#x73B0;&#x7C7B;&#x4F3C;kubectl &#x4E00;&#x6837;&#x7684;client &#xFF0C;&#x53EF;&#x4EE5;apply &#x4EFB;&#x610F;yaml&#x6587;&#x4EF6;</li>
</ol>
<ul>
<li>&#x5173;&#x952E;&#x4EE3;&#x7801;&#x4E4B;&#xFF1A;<strong>&#x5BF9;&#x8C61;&#x53CD;&#x5E8F;&#x5217;&#x5316;</strong></li>
</ul>
<pre class="language-"><code class="lang-go">
<span class="token keyword">var</span> <span class="token punctuation">(</span>
  <span class="token comment">// &#x89E3;&#x7801;&#x5668;</span>
    decode <span class="token operator">=</span> unstructured<span class="token punctuation">.</span>UnstructuredJSONScheme
<span class="token punctuation">)</span>

<span class="token keyword">func</span> <span class="token function">GetKubernetesObjectByBytes</span><span class="token punctuation">(</span>ioBytes <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">)</span> <span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token keyword">interface</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    objList <span class="token operator">:=</span> <span class="token function">make</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token keyword">interface</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span>
    d <span class="token operator">:=</span> yaml<span class="token punctuation">.</span><span class="token function">NewYAMLOrJSONDecoder</span><span class="token punctuation">(</span>bytes<span class="token punctuation">.</span><span class="token function">NewReader</span><span class="token punctuation">(</span>ioBytes<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">4096</span><span class="token punctuation">)</span>

    <span class="token keyword">for</span> <span class="token punctuation">{</span>
        ext <span class="token operator">:=</span> runtime<span class="token punctuation">.</span>RawExtension<span class="token punctuation">{</span><span class="token punctuation">}</span>
        <span class="token keyword">if</span> err <span class="token operator">:=</span> d<span class="token punctuation">.</span><span class="token function">Decode</span><span class="token punctuation">(</span><span class="token operator">&amp;</span>ext<span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> err <span class="token operator">==</span> io<span class="token punctuation">.</span>EOF <span class="token punctuation">{</span>
                <span class="token keyword">return</span> objList<span class="token punctuation">,</span> <span class="token boolean">nil</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token comment">// TODO: This needs to be able to handle object in other encodings and schemas.</span>
        ext<span class="token punctuation">.</span>Raw <span class="token operator">=</span> bytes<span class="token punctuation">.</span><span class="token function">TrimSpace</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">)</span>
        <span class="token keyword">if</span> <span class="token function">len</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span> <span class="token operator">||</span> bytes<span class="token punctuation">.</span><span class="token function">Equal</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token function">byte</span><span class="token punctuation">(</span><span class="token string">&quot;null&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> objList<span class="token punctuation">,</span> <span class="token boolean">nil</span>
        <span class="token punctuation">}</span>

    <span class="token comment">// &#x53C2;&#x6570;data &#x5FC5;&#x987B;&#x5148;yaml to json&#xFF0C;&#x5426;&#x5219;&#x4F1A;&#x62A5;&#x9519;</span>
        obj<span class="token punctuation">,</span> <span class="token boolean">_</span><span class="token punctuation">,</span> err <span class="token operator">:=</span> decode<span class="token punctuation">.</span><span class="token function">Decode</span><span class="token punctuation">(</span>ext<span class="token punctuation">.</span>Raw<span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">)</span>
        <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
        <span class="token punctuation">}</span>
        objList <span class="token operator">=</span> <span class="token function">append</span><span class="token punctuation">(</span>objList<span class="token punctuation">,</span> obj<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x4E3A;&#x4EC0;&#x4E48;yaml &#x5FC5;&#x987B;&#x8981;&#x8F6C;&#x6362;&#x4E3A; json</p>
<pre class="language-"><code class="lang-go"><span class="token comment">// YAMLToJSON converts YAML to JSON. Since JSON is a subset of YAML,</span>
<span class="token comment">// passing JSON through this method should be a no-op.</span>
<span class="token comment">//</span>
<span class="token comment">// Things YAML can do that are not supported by JSON:</span>
<span class="token comment">// * In YAML you can have binary and null keys in your maps. These are invalid</span>
<span class="token comment">//   in JSON. (int and float keys are converted to strings.)</span>
<span class="token comment">// * Binary data in YAML with the !!binary tag is not supported. If you want to</span>
<span class="token comment">//   use binary data with this library, encode the data as base64 as usual but do</span>
<span class="token comment">//   not use the !!binary tag in your YAML. This will ensure the original base64</span>
<span class="token comment">//   encoded data makes it all the way through to the JSON.</span>
<span class="token comment">//</span>
<span class="token comment">// For strict decoding of YAML, use YAMLToJSONStrict.</span>
<span class="token keyword">func</span> <span class="token function">YAMLToJSON</span><span class="token punctuation">(</span>y <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">)</span> <span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
   <span class="token keyword">return</span> <span class="token function">yamlToJSON</span><span class="token punctuation">(</span>y<span class="token punctuation">,</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> yaml<span class="token punctuation">.</span>Unmarshal<span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre>
<ul>
<li>&#x5173;&#x952E;&#x4EE3;&#x7801;&#x4E4B;&#xFF1A; <strong>&#x5BF9;&#x8C61;apply</strong></li>
</ul>
<p>client &#x8981;&#x5B9E;&#x73B0;apply &#x9700;&#x8981;&#x5B9E;&#x73B0;&#x4E24;&#x4E2A;&#x63A5;&#x53E3;&#xFF1A; creator &#x548C; patcher&#x3002;</p>
<p>creator &#x8D1F;&#x8D23;&#x83B7;&#x53D6;&#x96C6;&#x7FA4;&#x4E2D;&#x4EE5;&#x5B58;&#x5728;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x4E0D;&#x5B58;&#x5728;&#x5219;&#x521B;&#x5EFA;&#x3002;</p>
<p>patcher &#x8D1F;&#x8D23;&#x5BF9;&#x5C06;&#x96C6;&#x7FA4;&#x4E2D;&#x7684;&#x5BF9;&#x8C61;&#x66F4;&#x65B0;&#x4E3A;&#x8981;&#x4FEE;&#x6539;&#x7684;&#x5BF9;&#x8C61;&#x3002;</p>
<pre class="language-"><code class="lang-go"><span class="token keyword">func</span> <span class="token function">NewClient</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">*</span>KubernetesClient <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token operator">&amp;</span>KubernetesClient<span class="token punctuation">{</span>
    <span class="token comment">// &#x4E0D;&#x5B58;&#x5728;&#x5219;&#x521B;&#x5EFA;&#xFF0C;&#x5B58;&#x5728;&#x5219;&#x83B7;&#x53D6;&#x670D;&#x52A1;&#x7AEF;&#x5BF9;&#x8C61;</span>
        creator<span class="token punctuation">:</span> <span class="token function">creatorFn</span><span class="token punctuation">(</span>createOrGetExisting<span class="token punctuation">)</span><span class="token punctuation">,</span>

    <span class="token comment">// apply &#x7684;&#x5173;&#x952E;&#x65B9;&#x6CD5;&#xFF0C;&#x540E;&#x9762;&#x518D;&#x5177;&#x4F53;&#x4ECB;&#x7ECD;</span>
        patcher<span class="token punctuation">:</span> <span class="token function">patcherFn</span><span class="token punctuation">(</span>threeWayMergePatch<span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>


<span class="token comment">// Apply applies new state to an object or create it if not exist</span>
<span class="token keyword">func</span> <span class="token punctuation">(</span>k <span class="token operator">*</span>KubernetesClient<span class="token punctuation">)</span> <span class="token function">Apply</span><span class="token punctuation">(</span>ctx context<span class="token punctuation">.</span>Context<span class="token punctuation">,</span> desired client<span class="token punctuation">.</span>Object<span class="token punctuation">,</span> ao <span class="token operator">...</span>ApplyOption<span class="token punctuation">)</span> <span class="token builtin">error</span> <span class="token punctuation">{</span>
    existing<span class="token punctuation">,</span> err <span class="token operator">:=</span> k<span class="token punctuation">.</span><span class="token function">createOrGetExisting</span><span class="token punctuation">(</span>ctx<span class="token punctuation">,</span> k<span class="token punctuation">.</span>Client<span class="token punctuation">,</span> desired<span class="token punctuation">,</span> ao<span class="token operator">...</span><span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> err
    <span class="token punctuation">}</span>
  <span class="token comment">// existing &#x4E3A;nil&#xFF0C;&#x8868;&#x660E;&#x8FD9;&#x662F;&#x7B2C;&#x4E00;&#x6B21;&#x521B;&#x5EFA;&#xFF0C;&#x76F4;&#x63A5;&#x9000;&#x51FA;</span>
    <span class="token keyword">if</span> existing <span class="token operator">==</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// the object already exists, patch new state</span>
    <span class="token keyword">if</span> err <span class="token operator">:=</span> <span class="token function">executeApplyOptions</span><span class="token punctuation">(</span>ctx<span class="token punctuation">,</span> existing<span class="token punctuation">,</span> desired<span class="token punctuation">,</span> ao<span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> err
    <span class="token punctuation">}</span>
    <span class="token function">loggingApply</span><span class="token punctuation">(</span><span class="token string">&quot;patching object&quot;</span><span class="token punctuation">,</span> desired<span class="token punctuation">)</span>
  <span class="token comment">// &#x5982;&#x679C;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#xFF0C;&#x8FD9;&#x91CC;&#x6267;&#x884C;threeWayMergePatch</span>
    patch<span class="token punctuation">,</span> err <span class="token operator">:=</span> k<span class="token punctuation">.</span>patcher<span class="token punctuation">.</span><span class="token function">patch</span><span class="token punctuation">(</span>existing<span class="token punctuation">,</span> desired<span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> errors<span class="token punctuation">.</span><span class="token function">Wrap</span><span class="token punctuation">(</span>err<span class="token punctuation">,</span> <span class="token string">&quot;cannot calculate patch by computing a three way diff&quot;</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> errors<span class="token punctuation">.</span><span class="token function">Wrapf</span><span class="token punctuation">(</span>k<span class="token punctuation">.</span>Client<span class="token punctuation">.</span><span class="token function">Patch</span><span class="token punctuation">(</span>ctx<span class="token punctuation">,</span> desired<span class="token punctuation">,</span> patch<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token string">&quot;cannot patch object&quot;</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre>
<p>threeWayMergePatch&#xFF1A; &#x901A;&#x8FC7;&#x5C06; &#x96C6;&#x7FA4;&#x4E2D;&#x7684;&#x5BF9;&#x8C61;&#xFF08;current&#xFF09;&#xFF0C;apply&#x540E;&#x7684;&#x5BF9;&#x8C61;&#xFF08;modified&#xFF09;&#xFF0C; &#x5B58;&#x5728;&#x4E8E;&#x6CE8;&#x89E3;&#x4E2D;&#x7684;&#x5BF9;&#x8C61;&#xFF08;original&#xFF09;&#x4E09;&#x8005;&#x5BF9;&#x6BD4;&#xFF0C;&#x6839;&#x636E;&#x5728;runtime&#x4E2D;&#x662F;&#x5426;&#x6CE8;&#x518C;&#x6539;&#x5BF9;&#x8C61;&#xFF0C;&#x53C8;&#x5206;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;patch&#x3002;</p>
<p><strong>&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x5728;runtime&#x4E2D;&#x6CA1;&#x6709;&#x6CE8;&#x518C;</strong>&#xFF1A; &#x4F7F;&#x7528;<a href="https://tools.ietf.org/html/rfc7386" target="_blank">JSON Merge Patch, RFC 7386</a>&#xFF0C;&#x5BF9;<a href="https://tools.ietf.org/html/rfc6902" target="_blank">JSON Patch, RFC 6902</a> &#x8FDB;&#x884C;&#x4E86;&#x7B80;&#x5316;&#x3002; &#x4F46;&#x662F;&#x4ECD;&#x7136;&#x6709;&#x5982;&#x4E0B;&#x7F3A;&#x9677;&#xFF1A;1. delete must set null&#xFF1B; 2. add new element must report entire array&#x3002;3. &#x7F3A;&#x5C11;JSON Schema&#x9A8C;&#x8BC1;&#x3002;</p>
<p><strong>&#x8D44;&#x6E90;&#x5BF9;&#x8C61;&#x5728;runtime&#x4E2D;&#x6709;&#x6CE8;&#x518C;</strong>&#xFF1A;&#x4F7F;&#x7528;StrategicMergePatch&#x3002;&#x4E0D;&#x5FC5;&#x63D0;&#x4F9B;&#x5B8C;&#x6574;&#x7684;&#x5B57;&#x6BB5;&#xFF0C;&#x65B0;&#x5B57;&#x6BB5;&#x4F1A;&#x6DFB;&#x52A0;&#xFF0C;&#x51FA;&#x73B0;&#x7684;&#x5DF2;&#x6709;&#x5B57;&#x6BB5;&#x4F1A;&#x66F4;&#x65B0;&#xFF0C;&#x6CA1;&#x6709;&#x51FA;&#x73B0;&#x7684;&#x5DF2;&#x6709;&#x5B57;&#x6BB5;&#x4E0D;&#x53D8;&#x3002;&#x7F3A;&#x70B9;&#x662F;&#x4E0D;&#x652F;&#x6301; custom resource&#x3002;</p>
<pre class="language-"><code class="lang-go"><span class="token keyword">func</span> <span class="token function">threeWayMergePatch</span><span class="token punctuation">(</span>currentObj<span class="token punctuation">,</span> modifiedObj client<span class="token punctuation">.</span>Object<span class="token punctuation">)</span> <span class="token punctuation">(</span>client<span class="token punctuation">.</span>Patch<span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">// &#x96C6;&#x4E2D;&#x7684;&#x5BF9;&#x8C61;</span>
    current<span class="token punctuation">,</span> err <span class="token operator">:=</span> json<span class="token punctuation">.</span><span class="token function">Marshal</span><span class="token punctuation">(</span>currentObj<span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
    <span class="token punctuation">}</span>
  <span class="token comment">// &#x96C6;&#x4E2D;&#x7684;&#x5BF9;&#x8C61;&#x7684;&#x6CE8;&#x89E3;&#x503C; xxx/last-applied-configuration: {}</span>
    original<span class="token punctuation">,</span> err <span class="token operator">:=</span> <span class="token function">getOriginalConfiguration</span><span class="token punctuation">(</span>currentObj<span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
    <span class="token punctuation">}</span>
  <span class="token comment">// apply &#x540E;&#x7684;&#x5BF9;&#x8C61;</span>
    modified<span class="token punctuation">,</span> err <span class="token operator">:=</span> <span class="token function">getModifiedConfiguration</span><span class="token punctuation">(</span>modifiedObj<span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span>
    <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
    <span class="token punctuation">}</span>

    <span class="token keyword">var</span> patchType types<span class="token punctuation">.</span>PatchType
    <span class="token keyword">var</span> patchData <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span>
    <span class="token keyword">var</span> lookupPatchMeta strategicpatch<span class="token punctuation">.</span>LookupPatchMeta

    versionedObject<span class="token punctuation">,</span> err <span class="token operator">:=</span> k8sScheme<span class="token punctuation">.</span><span class="token function">New</span><span class="token punctuation">(</span>currentObj<span class="token punctuation">.</span><span class="token function">GetObjectKind</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">GroupVersionKind</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token keyword">switch</span> <span class="token punctuation">{</span>
  <span class="token comment">// crd &#x5BF9;&#x8C61;&#xFF0C;&#x5728;&#x9ED8;&#x8BA4;&#x7684;runtime&#x4E2D;&#x662F;&#x6CA1;&#x6709;&#x6CE8;&#x518C;&#x7684;</span>
    <span class="token keyword">case</span> runtime<span class="token punctuation">.</span><span class="token function">IsNotRegisteredError</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span><span class="token punctuation">:</span>
        <span class="token comment">// use JSONMergePatch for custom resources</span>
        <span class="token comment">// because StrategicMergePatch doesn&apos;t support custom resources</span>
        patchType <span class="token operator">=</span> types<span class="token punctuation">.</span>MergePatchType
        preconditions <span class="token operator">:=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>mergepatch<span class="token punctuation">.</span>PreconditionFunc<span class="token punctuation">{</span>
            mergepatch<span class="token punctuation">.</span><span class="token function">RequireKeyUnchanged</span><span class="token punctuation">(</span><span class="token string">&quot;apiVersion&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            mergepatch<span class="token punctuation">.</span><span class="token function">RequireKeyUnchanged</span><span class="token punctuation">(</span><span class="token string">&quot;kind&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            mergepatch<span class="token punctuation">.</span><span class="token function">RequireMetadataKeyUnchanged</span><span class="token punctuation">(</span><span class="token string">&quot;name&quot;</span><span class="token punctuation">)</span><span class="token punctuation">}</span>
        patchData<span class="token punctuation">,</span> err <span class="token operator">=</span> jsonmergepatch<span class="token punctuation">.</span><span class="token function">CreateThreeWayJSONMergePatch</span><span class="token punctuation">(</span>original<span class="token punctuation">,</span> modified<span class="token punctuation">,</span> current<span class="token punctuation">,</span> preconditions<span class="token operator">...</span><span class="token punctuation">)</span>
        <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
        <span class="token punctuation">}</span>
    <span class="token keyword">case</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span><span class="token punctuation">:</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
    <span class="token keyword">default</span><span class="token punctuation">:</span>
        <span class="token comment">// use StrategicMergePatch for K8s built-in resources</span>
        patchType <span class="token operator">=</span> types<span class="token punctuation">.</span>StrategicMergePatchType
        lookupPatchMeta<span class="token punctuation">,</span> err <span class="token operator">=</span> strategicpatch<span class="token punctuation">.</span><span class="token function">NewPatchMetaFromStruct</span><span class="token punctuation">(</span>versionedObject<span class="token punctuation">)</span>
        <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
        <span class="token punctuation">}</span>
        patchData<span class="token punctuation">,</span> err <span class="token operator">=</span> strategicpatch<span class="token punctuation">.</span><span class="token function">CreateThreeWayMergePatch</span><span class="token punctuation">(</span>original<span class="token punctuation">,</span> modified<span class="token punctuation">,</span> current<span class="token punctuation">,</span> lookupPatchMeta<span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span>
        <span class="token keyword">if</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> err
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> client<span class="token punctuation">.</span><span class="token function">RawPatch</span><span class="token punctuation">(</span>patchType<span class="token punctuation">,</span> patchData<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token boolean">nil</span>
<span class="token punctuation">}</span>
</code></pre>
<p>&#x8BE6;&#x7EC6;&#x4EE3;&#x7801;&#x89C1;&#xFF1A; <a href="https://github.com/xishengcai/ganni-tool/blob/master/k8s/kubeapp.go" target="_blank">https://github.com/xishengcai/ganni-tool/blob/master/k8s/kubeapp.go</a></p>
<p>&#x6211;&#x4EEC;&#x4EE5;&#x4E0B;&#x9762;&#x7684;yaml &#x4E3A;&#x4F8B;&#xFF0C;&#x6267;&#x884C;apply&#xFF0C;&#x7136;&#x540E;debug&#xFF0C;&#x89C2;&#x5BDF;threeWayMergePatch&#x4E2D;&#x7684;&#x5BF9;&#x8C61;</p>
<pre class="language-"><code class="lang-yaml"><span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> v1
<span class="token key atrule">kind</span><span class="token punctuation">:</span> Namespace
<span class="token key atrule">metadata</span><span class="token punctuation">:</span>
  <span class="token key atrule">name</span><span class="token punctuation">:</span> launcher<span class="token punctuation">-</span>test
<span class="token punctuation">---</span>
<span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> apiextensions.k8s.io/v1
<span class="token key atrule">kind</span><span class="token punctuation">:</span> CustomResourceDefinition
<span class="token key atrule">metadata</span><span class="token punctuation">:</span>
  <span class="token comment"># &#x540D;&#x5B57;&#x5FC5;&#x9700;&#x4E0E;&#x4E0B;&#x9762;&#x7684; spec &#x5B57;&#x6BB5;&#x5339;&#x914D;&#xFF0C;&#x5E76;&#x4E14;&#x683C;&#x5F0F;&#x4E3A; &apos;&lt;&#x540D;&#x79F0;&#x7684;&#x590D;&#x6570;&#x5F62;&#x5F0F;&gt;.&lt;&#x7EC4;&#x540D;&gt;&apos;</span>
  <span class="token key atrule">name</span><span class="token punctuation">:</span> crontabs.stable.example.com
<span class="token key atrule">spec</span><span class="token punctuation">:</span>
  <span class="token comment"># &#x7EC4;&#x540D;&#x79F0;&#xFF0C;&#x7528;&#x4E8E; REST API: /apis/&lt;&#x7EC4;&gt;/&lt;&#x7248;&#x672C;&gt;</span>
  <span class="token key atrule">group</span><span class="token punctuation">:</span> stable.example.com
  <span class="token comment"># &#x5217;&#x4E3E;&#x6B64; CustomResourceDefinition &#x6240;&#x652F;&#x6301;&#x7684;&#x7248;&#x672C;</span>
  <span class="token key atrule">versions</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> v1
      <span class="token comment"># &#x6BCF;&#x4E2A;&#x7248;&#x672C;&#x90FD;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; served &#x6807;&#x5FD7;&#x6765;&#x72EC;&#x7ACB;&#x542F;&#x7528;&#x6216;&#x7981;&#x6B62;</span>
      <span class="token key atrule">served</span><span class="token punctuation">:</span> <span class="token boolean important">true</span>
      <span class="token comment"># &#x5176;&#x4E2D;&#x4E00;&#x4E2A;&#x4E14;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x7248;&#x672C;&#x5FC5;&#x9700;&#x88AB;&#x6807;&#x8BB0;&#x4E3A;&#x5B58;&#x50A8;&#x7248;&#x672C;</span>
      <span class="token key atrule">storage</span><span class="token punctuation">:</span> <span class="token boolean important">true</span>
      <span class="token key atrule">schema</span><span class="token punctuation">:</span>
        <span class="token key atrule">openAPIV3Schema</span><span class="token punctuation">:</span>
          <span class="token key atrule">type</span><span class="token punctuation">:</span> object
          <span class="token key atrule">properties</span><span class="token punctuation">:</span>
            <span class="token key atrule">spec</span><span class="token punctuation">:</span>
              <span class="token key atrule">type</span><span class="token punctuation">:</span> object
              <span class="token key atrule">properties</span><span class="token punctuation">:</span>
                <span class="token key atrule">cronSpec</span><span class="token punctuation">:</span>
                  <span class="token key atrule">type</span><span class="token punctuation">:</span> string
                <span class="token key atrule">image</span><span class="token punctuation">:</span>
                  <span class="token key atrule">type</span><span class="token punctuation">:</span> string
                <span class="token key atrule">replicas</span><span class="token punctuation">:</span>
                  <span class="token key atrule">type</span><span class="token punctuation">:</span> integer
  <span class="token comment"># &#x53EF;&#x4EE5;&#x662F; Namespaced &#x6216; Cluster</span>
  <span class="token key atrule">scope</span><span class="token punctuation">:</span> Namespaced
  <span class="token key atrule">names</span><span class="token punctuation">:</span>
    <span class="token comment"># &#x540D;&#x79F0;&#x7684;&#x590D;&#x6570;&#x5F62;&#x5F0F;&#xFF0C;&#x7528;&#x4E8E; URL&#xFF1A;/apis/&lt;&#x7EC4;&gt;/&lt;&#x7248;&#x672C;&gt;/&lt;&#x540D;&#x79F0;&#x7684;&#x590D;&#x6570;&#x5F62;&#x5F0F;&gt;</span>
    <span class="token key atrule">plural</span><span class="token punctuation">:</span> crontabs
    <span class="token comment"># &#x540D;&#x79F0;&#x7684;&#x5355;&#x6570;&#x5F62;&#x5F0F;&#xFF0C;&#x4F5C;&#x4E3A;&#x547D;&#x4EE4;&#x884C;&#x4F7F;&#x7528;&#x65F6;&#x548C;&#x663E;&#x793A;&#x65F6;&#x7684;&#x522B;&#x540D;</span>
    <span class="token key atrule">singular</span><span class="token punctuation">:</span> crontab
    <span class="token comment"># kind &#x901A;&#x5E38;&#x662F;&#x5355;&#x6570;&#x5F62;&#x5F0F;&#x7684;&#x9A7C;&#x5CF0;&#x7F16;&#x7801;&#xFF08;CamelCased&#xFF09;&#x5F62;&#x5F0F;&#x3002;&#x4F60;&#x7684;&#x8D44;&#x6E90;&#x6E05;&#x5355;&#x4F1A;&#x4F7F;&#x7528;&#x8FD9;&#x4E00;&#x5F62;&#x5F0F;&#x3002;</span>
    <span class="token key atrule">kind</span><span class="token punctuation">:</span> CronTab
    <span class="token comment"># shortNames &#x5141;&#x8BB8;&#x4F60;&#x5728;&#x547D;&#x4EE4;&#x884C;&#x4F7F;&#x7528;&#x8F83;&#x77ED;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x6765;&#x5339;&#x914D;&#x8D44;&#x6E90;</span>
    <span class="token key atrule">shortNames</span><span class="token punctuation">:</span>
      <span class="token punctuation">-</span> ct
<span class="token punctuation">---</span>
<span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> stable.example.com/v1
<span class="token key atrule">kind</span><span class="token punctuation">:</span> CronTab
<span class="token key atrule">metadata</span><span class="token punctuation">:</span>
  <span class="token key atrule">name</span><span class="token punctuation">:</span> crontab
  <span class="token key atrule">namespace</span><span class="token punctuation">:</span> launcher<span class="token punctuation">-</span>test
<span class="token key atrule">spec</span><span class="token punctuation">:</span>
  <span class="token key atrule">image</span><span class="token punctuation">:</span> <span class="token string">&quot;xx&quot;</span>
  <span class="token key atrule">replicas</span><span class="token punctuation">:</span> <span class="token number">1</span>
<span class="token punctuation">---</span>
<span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> stable.example.com/v1
<span class="token key atrule">kind</span><span class="token punctuation">:</span> CronTab
<span class="token key atrule">metadata</span><span class="token punctuation">:</span>
  <span class="token key atrule">name</span><span class="token punctuation">:</span> crontab
  <span class="token key atrule">namespace</span><span class="token punctuation">:</span> launcher<span class="token punctuation">-</span>test
<span class="token key atrule">spec</span><span class="token punctuation">:</span>
  <span class="token key atrule">image</span><span class="token punctuation">:</span> <span class="token string">&quot;xxx&quot;</span>
  <span class="token key atrule">replicas</span><span class="token punctuation">:</span> <span class="token number">2</span>
</code></pre>
<p>&#x7ED3;&#x679C;&#x5982;&#x4E0B;</p>
<p>current&#xFF1A;</p>
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span>
  <span class="token property">&quot;apiVersion&quot;</span><span class="token operator">:</span> <span class="token string">&quot;stable.example.com/v1&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;kind&quot;</span><span class="token operator">:</span> <span class="token string">&quot;CronTab&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;metadata&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">&quot;annotations&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
      <span class="token property">&quot;ganni-tool/last-applied-configuration&quot;</span><span class="token operator">:</span> <span class="token string">&quot;{\&quot;apiVersion\&quot;:\&quot;stable.example.com/v1\&quot;,\&quot;kind\&quot;:\&quot;CronTab\&quot;,\&quot;metadata\&quot;:{\&quot;name\&quot;:\&quot;crontab\&quot;,\&quot;namespace\&quot;:\&quot;launcher-test\&quot;},\&quot;spec\&quot;:{\&quot;image\&quot;:\&quot;xx\&quot;,\&quot;replicas\&quot;:1}}&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token property">&quot;creationTimestamp&quot;</span><span class="token operator">:</span> <span class="token string">&quot;2021-06-03T03:08:29Z&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;generation&quot;</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
    <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;crontab&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;namespace&quot;</span><span class="token operator">:</span> <span class="token string">&quot;launcher-test&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;resourceVersion&quot;</span><span class="token operator">:</span> <span class="token string">&quot;16154&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;selfLink&quot;</span><span class="token operator">:</span> <span class="token string">&quot;/apis/stable.example.com/v1/namespaces/launcher-test/crontabs/crontab&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;uid&quot;</span><span class="token operator">:</span> <span class="token string">&quot;7705fc1e-1a1c-457d-b9dd-9ff56658343d&quot;</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token property">&quot;spec&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">&quot;image&quot;</span><span class="token operator">:</span> <span class="token string">&quot;xx&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;replicas&quot;</span><span class="token operator">:</span> <span class="token number">1</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>Origin:</p>
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span>
  <span class="token property">&quot;apiVersion&quot;</span><span class="token operator">:</span> <span class="token string">&quot;stable.example.com/v1&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;kind&quot;</span><span class="token operator">:</span> <span class="token string">&quot;CronTab&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;metadata&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;crontab&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;namespace&quot;</span><span class="token operator">:</span> <span class="token string">&quot;launcher-test&quot;</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token property">&quot;spec&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">&quot;image&quot;</span><span class="token operator">:</span> <span class="token string">&quot;xx&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;replicas&quot;</span><span class="token operator">:</span> <span class="token number">1</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>Modify:</p>
<pre class="language-"><code class="lang-json"><span class="token punctuation">{</span>
  <span class="token property">&quot;apiVersion&quot;</span><span class="token operator">:</span> <span class="token string">&quot;stable.example.com/v1&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;kind&quot;</span><span class="token operator">:</span> <span class="token string">&quot;CronTab&quot;</span><span class="token punctuation">,</span>
  <span class="token property">&quot;metadata&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">&quot;annotations&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
      <span class="token property">&quot;ganni-tool/last-applied-configuration&quot;</span><span class="token operator">:</span> <span class="token string">&quot;{\&quot;apiVersion\&quot;:\&quot;stable.example.com/v1\&quot;,\&quot;kind\&quot;:\&quot;CronTab\&quot;,\&quot;metadata\&quot;:{\&quot;name\&quot;:\&quot;crontab\&quot;,\&quot;namespace\&quot;:\&quot;launcher-test\&quot;},\&quot;spec\&quot;:{\&quot;image\&quot;:\&quot;xxx\&quot;,\&quot;replicas\&quot;:2}}&quot;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token property">&quot;name&quot;</span><span class="token operator">:</span> <span class="token string">&quot;crontab&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;namespace&quot;</span><span class="token operator">:</span> <span class="token string">&quot;launcher-test&quot;</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token property">&quot;spec&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token property">&quot;image&quot;</span><span class="token operator">:</span> <span class="token string">&quot;xxx&quot;</span><span class="token punctuation">,</span>
    <span class="token property">&quot;replicas&quot;</span><span class="token operator">:</span> <span class="token number">2</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p><strong>Question</strong>:</p>
<p><strong>Q1</strong>&#xFF1A;&#x4E3A;&#x4EC0;&#x4E48;kubectl &#x5728;&#x6CA1;&#x6709;&#x6CE8;&#x518C;scheme &#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x53EF;&#x4EE5;&#x751F;&#x6210;runtime.Object</p>
<p><strong>A</strong>&#xFF1A;&#x56E0;&#x4E3A;kubectl &#x4F7F;&#x7528;&#x7684;&#x662F; UnstructuredJSONScheme&#xFF0C; &#x53EF;&#x4EE5;&#x4E0D;&#x9700;&#x8981;&#x63D0;&#x6CE8;&#x518C;scheme&#xFF08;without a predefined scheme&#xFF09;&#x3002;</p>
<p>UnstructuredJSONScheme.Decode &#x65B9;&#x6CD5;&#x5C06; yaml or json &#x7684;&#x5B57;&#x8282;&#x6D41;&#x8F6C;&#x6362;&#x6210;&#x4E86; Unstructured.Object&#xFF08; &#x800C;object &#x7684;&#x7C7B;&#x578B;&#x662F;map[string]interface{}&#xFF09;&#x3002;</p>
<p>&#x4E0B;&#x9762;&#x4EE3;&#x7801;&#x662F;UnstructuredJSONScheme&#x53CD;&#x5E8F;&#x5217;&#x5316;&#x6D41;&#x7A0B;</p>
<p>&#x4EE3;&#x7801;&#x4F4D;&#x7F6E;&#xFF1A; staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go  </p>
<p>&#x7248;&#x672C;&#xFF1A;v1.19.0</p>
<pre class="language-"><code class="lang-go">        <span class="token comment">// UnstructuredJSONScheme is capable of converting JSON data into the Unstructured</span>
        <span class="token comment">// type, which can be used for generic access to objects without a predefined scheme.</span>
        <span class="token comment">// TODO: move into serializer/json.</span>
<span class="token number">329</span>  <span class="token keyword">var</span> UnstructuredJSONScheme runtime<span class="token punctuation">.</span>Codec <span class="token operator">=</span> unstructuredJSONScheme<span class="token punctuation">{</span><span class="token punctuation">}</span>


<span class="token number">335</span> <span class="token keyword">func</span> <span class="token punctuation">(</span>s unstructuredJSONScheme<span class="token punctuation">)</span> <span class="token function">Decode</span><span class="token punctuation">(</span>data <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">,</span> <span class="token boolean">_</span> <span class="token operator">*</span>schema<span class="token punctuation">.</span>GroupVersionKind<span class="token punctuation">,</span> obj runtime<span class="token punctuation">.</span>Object<span class="token punctuation">)</span> <span class="token punctuation">(</span>runtime<span class="token punctuation">.</span>Object<span class="token punctuation">,</span> <span class="token operator">*</span>schema<span class="token punctuation">.</span>GroupVersionKind<span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">var</span> err <span class="token builtin">error</span>
    <span class="token keyword">if</span> obj <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        err <span class="token operator">=</span> s<span class="token punctuation">.</span><span class="token function">decodeInto</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> obj<span class="token punctuation">)</span>
    <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
    <span class="token comment">//&#x6CE8;&#x610F; look down</span>
        obj<span class="token punctuation">,</span> err <span class="token operator">=</span> s<span class="token punctuation">.</span><span class="token function">decode</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
<span class="token operator">...</span>
    gvk <span class="token operator">:=</span> obj<span class="token punctuation">.</span><span class="token function">GetObjectKind</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">GroupVersionKind</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token keyword">if</span> <span class="token function">len</span><span class="token punctuation">(</span>gvk<span class="token punctuation">.</span>Kind<span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token boolean">nil</span><span class="token punctuation">,</span> <span class="token operator">&amp;</span>gvk<span class="token punctuation">,</span> runtime<span class="token punctuation">.</span><span class="token function">NewMissingKindErr</span><span class="token punctuation">(</span><span class="token function">string</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">return</span> obj<span class="token punctuation">,</span> <span class="token operator">&amp;</span>gvk<span class="token punctuation">,</span> <span class="token boolean">nil</span>
<span class="token punctuation">}</span>

<span class="token number">391</span> <span class="token keyword">func</span> <span class="token punctuation">(</span>s unstructuredJSONScheme<span class="token punctuation">)</span> <span class="token function">decode</span><span class="token punctuation">(</span>data <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">)</span> <span class="token punctuation">(</span>runtime<span class="token punctuation">.</span>Object<span class="token punctuation">,</span> <span class="token builtin">error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token operator">...</span>
    <span class="token comment">// No Items field, so it wasn&apos;t a list.</span>
    unstruct <span class="token operator">:=</span> <span class="token operator">&amp;</span>Unstructured<span class="token punctuation">{</span><span class="token punctuation">}</span>
    <span class="token comment">//&#x6CE8;&#x610F; look down&#xFF0C;</span>
    err <span class="token operator">:=</span> s<span class="token punctuation">.</span><span class="token function">decodeToUnstructured</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> unstruct<span class="token punctuation">)</span>
    <span class="token keyword">return</span> unstruct<span class="token punctuation">,</span> err
<span class="token punctuation">}</span>

<span class="token number">343</span> <span class="token keyword">func</span> <span class="token punctuation">(</span>unstructuredJSONScheme<span class="token punctuation">)</span> <span class="token function">decodeToUnstructured</span><span class="token punctuation">(</span>data <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token builtin">byte</span><span class="token punctuation">,</span> unstruct <span class="token operator">*</span>Unstructured<span class="token punctuation">)</span> <span class="token builtin">error</span> <span class="token punctuation">{</span>
    m <span class="token operator">:=</span> <span class="token function">make</span><span class="token punctuation">(</span><span class="token keyword">map</span><span class="token punctuation">[</span><span class="token builtin">string</span><span class="token punctuation">]</span><span class="token keyword">interface</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token comment">// &#x6CE8;&#x610F;</span>
    <span class="token keyword">if</span> err <span class="token operator">:=</span> json<span class="token punctuation">.</span><span class="token function">Unmarshal</span><span class="token punctuation">(</span>data<span class="token punctuation">,</span> <span class="token operator">&amp;</span>m<span class="token punctuation">)</span><span class="token punctuation">;</span> err <span class="token operator">!=</span> <span class="token boolean">nil</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> err
    <span class="token punctuation">}</span>

    unstruct<span class="token punctuation">.</span>Object <span class="token operator">=</span> m

    <span class="token keyword">return</span> <span class="token boolean">nil</span>
<span class="token punctuation">}</span>
</code></pre>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; caixisheng 2017 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2021-06-10 19:45:30
</span></footer> <link rel="stylesheet" type="text/css" href="https://storage.googleapis.com/app.klipse.tech/css/codemirror.css"> <script>     window.klipse_settings = {         selector: ".language-klipse, .lang-eval-clojure",         selector_eval_js: ".lang-eval-js",         selector_eval_python_client: ".lang-eval-python",         selector_eval_php: ".lang-eval-php",         selector_eval_scheme: ".lang-eval-scheme",         selector_eval_ruby: ".lang-eval-ruby",         selector_reagent: ".lang-reagent",        selector_google_charts: ".lang-google-chart",        selector_es2017: ".lang-eval-es2017",        selector_jsx: ".lang-eval-jsx",        selector_transpile_jsx: ".lang-transpile-jsx",        selector_render_jsx: ".lang-render-jsx",        selector_react: ".lang-react",        selector_eval_markdown: ".lang-render-markdown",        selector_eval_lambdaway: ".lang-render-lambdaway",        selector_eval_cpp: ".lang-eval-cpp",        selector_eval_html: ".lang-render-html",        selector_sql: ".lang-eval-sql",        selector_brainfuck: "lang-eval-brainfuck",        selector_js: ".lang-transpile-cljs"    }; </script> <script src="https://storage.googleapis.com/app.klipse.tech/plugin/js/klipse_plugin.js"></script>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="schedule.html" class="navigation navigation-prev " aria-label="Previous page: Schedule">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="调度队列.html" class="navigation navigation-next " aria-label="Next page: 调度队列">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Scheme","level":"1.9.4.12","depth":3,"next":{"title":"调度队列","level":"1.9.4.13","depth":3,"path":"blog/kubernetes/K8s源码/调度队列.md","ref":"blog/kubernetes/K8s源码/调度队列.md","articles":[]},"previous":{"title":"Schedule","level":"1.9.4.11","depth":3,"path":"blog/kubernetes/K8s源码/schedule.md","ref":"blog/kubernetes/K8s源码/schedule.md","articles":[]},"dir":"ltr"},"config":{"plugins":["summary","expandable-chapters","toggle-chapters","theme-comscore","-lunr","-search","-highlight","-livereload","search-plus@^0.0.11","simple-page-toc@^0.1.1","github@^2.0.0","github-buttons@2.1.0","edit-link@^2.0.2","disqus@^0.1.0","prism@^2.1.0","prism-themes@^0.0.2","advanced-emoji@^0.2.1","anchors@^0.7.1","include-codeblock@^3.0.2","emphasize@^1.1.0","katex@^1.1.3","splitter@^0.0.8","mermaid-gb3@2.1.0","tbfed-pagefooter@^0.0.1","expandable-chapters-small@^0.1.7","sectionx@^3.1.0","donate@^1.0.2","local-video@^1.0.1","anchor-navigation-ex@0.1.8","favicon@^0.0.2","3-ba@^0.9.0","terminal@^0.3.2","alerts@^0.2.0","include-csv@^0.1.0","puml@^1.0.1","musicxml@^1.0.2","klipse@^1.2.0","versions-select@^0.1.1","-sharing","sharing-plus@^0.0.2","graph@^0.1.0","chart@^0.2.0"],"root":".","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright © caixisheng 2017","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prism-themes/themes/prism-base16-ateliersulphurpool.light.css"]},"include-csv":{},"disqus":{"useIdentifier":false,"shortName":"gitbookuse"},"emphasize":{},"github":{"url":"https://github.com/xishengcai/xisheng.blog"},"puml":{},"simple-page-toc":{"maxDepth":3,"skipFirstH1":true},"summary":{},"splitter":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"versions-select":{"type":"branches"},"graph":{},"donate":{"alipay":"https://cai-hello-1253732611.cos.ap-shanghai.myqcloud.com/share/zhifubao-pay.jpg","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"https://cai-hello-1253732611.cos.ap-shanghai.myqcloud.com/share/weixin-pay.jpg","wechatText":"微信打赏"},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":2},"musicxml":{},"sectionx":{"tag":"b"},"mermaid-gb3":{},"anchor-navigation-ex":{"isRewritePageTitle":false,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"},"favicon":{"shortcut":"favicon.ico","bookmark":"favicon.ico"},"theme-comscore":{},"prism-themes":{},"alerts":{},"github-buttons":{"repo":"xishengcai/xisheng.blog","types":["star"],"size":"small"},"3-ba":{"configuration":"auto","token":"ff100361cdce95dd4c8fb96b4009f7bc"},"expandable-chapters-small":{},"local-video":{},"klipse":{"myConfigKey":"it's the default value"},"advanced-emoji":{"embedEmojis":false},"include-codeblock":{"check":false,"edit":true,"fixlang":false,"lang":"","template":"ace","theme":"chrome","unindent":true},"sharing":{"qq":false,"all":["facebook","google","twitter","weibo","instapaper","linkedin","pocket","stumbleupon","qq","qzone"],"douban":false,"facebook":false,"weibo":true,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":false,"messenger":false,"line":false,"vk":false,"pocket":false,"google":true,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":true},"terminal":{"copyButtons":true,"fade":false,"style":"flat"},"edit-link":{"label":"Edit This Page","base":"https://github.com/xishengcai/xisheng.blog/edit/master"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":true},"anchors":{},"chart":{"type":"c3"},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"xishengcai","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"这是程序员吗","language":"zh-hans","output.name":"site","links":{"sidebar":{"Home":"https://xisheng.vip"}},"gitbook":"3.2.3","description":"这是程序员吗"},"file":{"path":"blog/kubernetes/K8s源码/scheme.md","mtime":"2021-06-10T11:45:30.944Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-06-23T07:51:54.455Z"},"basePath":"../../..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../../../gitbook/gitbook.js"></script>
    <script src="../../../gitbook/theme.js"></script>
    
        
        <script src="../../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.16.1/URI.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-disqus/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-3-ba/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-terminal/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-musicxml/osmd.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-musicxml/musicxml.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-musicxml/promise.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-versions-select/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    <script src="../../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

